[macruby-changes] [3174] MacRuby/trunk/file.c
source_changes at macosforge.org
source_changes at macosforge.org
Thu Dec 24 18:13:36 PST 2009
Revision: 3174
http://trac.macosforge.org/projects/ruby/changeset/3174
Author: lsansonetti at apple.com
Date: 2009-12-24 18:13:36 -0800 (Thu, 24 Dec 2009)
Log Message:
-----------
optimized #to_path
Modified Paths:
--------------
MacRuby/trunk/file.c
Modified: MacRuby/trunk/file.c
===================================================================
--- MacRuby/trunk/file.c 2009-12-25 02:13:12 UTC (rev 3173)
+++ MacRuby/trunk/file.c 2009-12-25 02:13:36 UTC (rev 3174)
@@ -15,8 +15,10 @@
#include "ruby/io.h"
#include "ruby/signal.h"
#include "ruby/util.h"
+#include "ruby/node.h"
#include "dln.h"
#include "objc.h"
+#include "vm.h"
#ifdef HAVE_UNISTD_H
#include <unistd.h>
@@ -91,26 +93,22 @@
VALUE rb_mFileTest;
VALUE rb_cStat;
+static SEL selToPath = 0;
+
static VALUE
rb_get_path_check(VALUE obj, int check)
{
- VALUE tmp;
- static ID to_path;
-
if (check) {
rb_check_safe_obj(obj);
}
- tmp = rb_check_string_type(obj);
+ VALUE tmp = rb_check_string_type(obj);
if (!NIL_P(tmp)) {
goto exit;
}
- if (!to_path) {
- to_path = rb_intern("to_path");
+ if (rb_vm_respond_to(obj, selToPath, true)) {
+ tmp = rb_vm_call(obj, selToPath, 0, NULL, false);
}
- if (rb_respond_to(obj, to_path)) {
- tmp = rb_funcall(obj, to_path, 0, 0);
- }
else {
tmp = obj;
}
@@ -3944,6 +3942,8 @@
rb_mFileTest = rb_define_module("FileTest");
rb_cFile = rb_define_class("File", rb_cIO);
+ selToPath = sel_registerName("to_path");
+
define_filetest_function("directory?", rb_file_directory_p, 1);
define_filetest_function("exist?", rb_file_exist_p, 1);
define_filetest_function("exists?", rb_file_exist_p, 1);
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/macruby-changes/attachments/20091224/e0a70d0f/attachment-0001.html>
More information about the macruby-changes
mailing list