From c57e8f7ddc816746e0541c26a3df6cdbd65ba435 Mon Sep 17 00:00:00 2001 From: akr Date: Sat, 31 Jul 2010 00:13:10 +0000 Subject: * ext/pathname/pathname.c (path_to_s): Pathname#to_s translated from pathname.rb. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@28805 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ext/pathname/lib/pathname.rb | 5 ----- ext/pathname/pathname.c | 10 ++++++++++ 2 files changed, 10 insertions(+), 5 deletions(-) (limited to 'ext/pathname') diff --git a/ext/pathname/lib/pathname.rb b/ext/pathname/lib/pathname.rb index 75705ff993..550939afd9 100644 --- a/ext/pathname/lib/pathname.rb +++ b/ext/pathname/lib/pathname.rb @@ -31,11 +31,6 @@ class Pathname # :startdoc: - # Return the path as a String. - def to_s - @path.dup - end - # to_path is implemented so Pathname objects are usable with File.open, etc. alias_method TO_PATH, :to_s diff --git a/ext/pathname/pathname.c b/ext/pathname/pathname.c index f437d7f859..20c7745863 100644 --- a/ext/pathname/pathname.c +++ b/ext/pathname/pathname.c @@ -126,6 +126,15 @@ path_hash(VALUE self) return INT2FIX(rb_str_hash(get_strpath(self))); } +/* + * Return the path as a String. + */ +static VALUE +path_to_s(VALUE self) +{ + return rb_obj_dup(get_strpath(self)); +} + /* * == Pathname * @@ -319,4 +328,5 @@ Init_pathname() 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); + rb_define_method(rb_cPathname, "to_s", path_to_s, 0); } -- cgit v1.2.3