diff options
-rw-r--r-- | ChangeLog | 7 | ||||
-rw-r--r-- | ext/pathname/lib/pathname.rb | 4 | ||||
-rw-r--r-- | ext/pathname/pathname.c | 8 |
3 files changed, 14 insertions, 5 deletions
@@ -1,3 +1,8 @@ +Fri Jul 30 21:43:55 2010 Tanaka Akira <akr@fsij.org> + + * ext/pathname/pathname.c (path_hash): Pathname#hash translated + from pathname.rb. + Fri Jul 30 12:42:02 2010 Nobuyoshi Nakada <nobu@ruby-lang.org> * lib/net/imap.rb (example): use IO#noecho to read password if @@ -30,7 +35,7 @@ Thu Jul 29 22:28:35 2010 Tanaka Akira <akr@fsij.org> * ext/pathname/pathname.c (path_cmp): Pathname#<=> translated from pathname.rb. - + Thu Jul 29 06:51:30 2010 Nobuyoshi Nakada <nobu@ruby-lang.org> * common.mk (EXT_SRCS): add ext/json/parser/parser.c. diff --git a/ext/pathname/lib/pathname.rb b/ext/pathname/lib/pathname.rb index 31dc9a361f..75705ff993 100644 --- a/ext/pathname/lib/pathname.rb +++ b/ext/pathname/lib/pathname.rb @@ -31,10 +31,6 @@ class Pathname # :startdoc: - def hash # :nodoc: - @path.hash - end - # Return the path as a String. def to_s @path.dup diff --git a/ext/pathname/pathname.c b/ext/pathname/pathname.c index 7b801a1c0b..f437d7f859 100644 --- a/ext/pathname/pathname.c +++ b/ext/pathname/pathname.c @@ -119,6 +119,13 @@ path_cmp(VALUE self, VALUE other) return INT2FIX(0); } +/* :nodoc: */ +static VALUE +path_hash(VALUE self) +{ + return INT2FIX(rb_str_hash(get_strpath(self))); +} + /* * == Pathname * @@ -311,4 +318,5 @@ Init_pathname() 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); } |