[前][次][番号順一覧][スレッド一覧]

ruby-changes:13649

From: knu <ko1@a...>
Date: Thu, 22 Oct 2009 17:51:55 +0900 (JST)
Subject: [ruby-changes:13649] Ruby:r25433 (trunk): * lib/fileutils.rb (FileUtils#fu_get_uid, fu_get_gid): Do not

knu	2009-10-22 17:51:40 +0900 (Thu, 22 Oct 2009)

  New Revision: 25433

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=25433

  Log:
    * lib/fileutils.rb (FileUtils#fu_get_uid, fu_get_gid): Do not
      convert an integer back and forth.

  Modified files:
    trunk/ChangeLog
    trunk/lib/fileutils.rb

Index: ChangeLog
===================================================================
--- ChangeLog	(revision 25432)
+++ ChangeLog	(revision 25433)
@@ -1,3 +1,8 @@
+Thu Oct 22 17:49:05 2009  Akinori MUSHA  <knu@i...>
+
+	* lib/fileutils.rb (FileUtils#fu_get_uid, fu_get_gid): Do not
+	  convert an integer back and forth.
+
 Thu Oct 22 17:29:51 2009  Nobuyoshi Nakada  <nobu@r...>
 
 	* parse.y (arg_prepend): removed.  a patch from Mikhail T. in
Index: lib/fileutils.rb
===================================================================
--- lib/fileutils.rb	(revision 25432)
+++ lib/fileutils.rb	(revision 25433)
@@ -977,20 +977,26 @@
 
     def fu_get_uid(user)   #:nodoc:
       return nil unless user
-      user = user.to_s
-      if /\A\d+\z/ =~ user
-      then user.to_i
-      else Etc.getpwnam(user).uid
+      case user
+      when Integer
+        user
+      when /\A\d+\z/
+        user.to_i
+      else
+        Etc.getpwnam(user).uid
       end
     end
     private_module_function :fu_get_uid
 
     def fu_get_gid(group)   #:nodoc:
       return nil unless group
-      group = group.to_s
-      if /\A\d+\z/ =~ group
-      then group.to_i
-      else Etc.getgrnam(group).gid
+      case group
+      when Integer
+        group
+      when /\A\d+\z/
+        group.to_i
+      else
+        Etc.getgrnam(group).gid
       end
     end
     private_module_function :fu_get_gid

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]