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

ruby-changes:16807

From: akr <ko1@a...>
Date: Fri, 30 Jul 2010 21:44:57 +0900 (JST)
Subject: [ruby-changes:16807] Ruby:r28802 (trunk): * ext/pathname/pathname.c (path_hash): Pathname#hash translated

akr	2010-07-30 21:44:41 +0900 (Fri, 30 Jul 2010)

  New Revision: 28802

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

  Log:
    * ext/pathname/pathname.c (path_hash): Pathname#hash translated
      from pathname.rb.

  Modified files:
    trunk/ChangeLog
    trunk/ext/pathname/lib/pathname.rb
    trunk/ext/pathname/pathname.c

Index: ChangeLog
===================================================================
--- ChangeLog	(revision 28801)
+++ ChangeLog	(revision 28802)
@@ -1,3 +1,8 @@
+Fri Jul 30 21:43:55 2010  Tanaka Akira  <akr@f...>
+
+	* ext/pathname/pathname.c (path_hash): Pathname#hash translated
+	  from pathname.rb.
+
 Fri Jul 30 12:42:02 2010  Nobuyoshi Nakada  <nobu@r...>
 
 	* lib/net/imap.rb (example): use IO#noecho to read password if
@@ -30,7 +35,7 @@
 
 	* ext/pathname/pathname.c (path_cmp): Pathname#<=> translated
 	  from pathname.rb.
-	
+
 Thu Jul 29 06:51:30 2010  Nobuyoshi Nakada  <nobu@r...>
 
 	* common.mk (EXT_SRCS): add ext/json/parser/parser.c.
Index: ext/pathname/lib/pathname.rb
===================================================================
--- ext/pathname/lib/pathname.rb	(revision 28801)
+++ ext/pathname/lib/pathname.rb	(revision 28802)
@@ -31,10 +31,6 @@
 
   # :startdoc:
 
-  def hash # :nodoc:
-    @path.hash
-  end
-
   # Return the path as a String.
   def to_s
     @path.dup
Index: ext/pathname/pathname.c
===================================================================
--- ext/pathname/pathname.c	(revision 28801)
+++ ext/pathname/pathname.c	(revision 28802)
@@ -119,6 +119,13 @@
     return INT2FIX(0);
 }
 
+/* :nodoc: */
+static VALUE
+path_hash(VALUE self)
+{
+    return INT2FIX(rb_str_hash(get_strpath(self)));
+}
+
 /*
  * == Pathname
  *
@@ -311,4 +318,5 @@
     rb_define_method(rb_cPathname, "===", path_eq, 1);
     rb_define_method(rb_cPathname, "eql?", path_eq, 1);
     rb_define_method(rb_cPathname, "<=>", path_cmp, 1);
+    rb_define_method(rb_cPathname, "hash", path_hash, 0);
 }

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

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