diff options
author | akr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2010-07-30 12:44:41 +0000 |
---|---|---|
committer | akr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2010-07-30 12:44:41 +0000 |
commit | be2f3c58e693a6e10693153ef2422b0235661e3e (patch) | |
tree | fd2bbf91bf9980293e594a1e310b9bd7f485bbbe /ext/pathname | |
parent | 47fd9eb6e16ca14ee9415e4e2734c28ce5eeca36 (diff) | |
download | ruby-be2f3c58e693a6e10693153ef2422b0235661e3e.tar.gz |
* ext/pathname/pathname.c (path_hash): Pathname#hash translated
from pathname.rb.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@28802 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ext/pathname')
-rw-r--r-- | ext/pathname/lib/pathname.rb | 4 | ||||
-rw-r--r-- | ext/pathname/pathname.c | 8 |
2 files changed, 8 insertions, 4 deletions
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); } |