summaryrefslogtreecommitdiff
path: root/string.c
diff options
context:
space:
mode:
authorshugo <shugo@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2012-12-08 02:37:16 +0000
committershugo <shugo@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2012-12-08 02:37:16 +0000
commitdb051011d68950cd1261f91e724513282d419d9e (patch)
treed27e726831d1555253d08477275055f7b5de0cf0 /string.c
parent3adc9834d18ee6ff67dfca060eee170025ce3fef (diff)
* eval.c (rb_mod_refine), vm_eval.c (rb_yield_refine_block):
Module#refine activates all refinements defined in that module only in a given block. * string.c (sym_to_proc, sym_call): don't use refinements. * test/ruby/test_refinement.rb: related test. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38269 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'string.c')
-rw-r--r--string.c45
1 files changed, 17 insertions, 28 deletions
diff --git a/string.c b/string.c
index 46661769e6..2033da2165 100644
--- a/string.c
+++ b/string.c
@@ -14,8 +14,7 @@
#include "ruby/ruby.h"
#include "ruby/re.h"
#include "ruby/encoding.h"
-#include "node.h"
-#include "eval_intern.h"
+#include "vm_core.h"
#include "internal.h"
#include "probes.h"
#include <assert.h>
@@ -7862,18 +7861,15 @@ sym_to_sym(VALUE sym)
}
static VALUE
-sym_call(VALUE args, VALUE p, int argc, VALUE *argv)
+sym_call(VALUE args, VALUE sym, int argc, VALUE *argv)
{
VALUE obj;
- NODE *memo = RNODE(p);
if (argc < 1) {
rb_raise(rb_eArgError, "no receiver given");
}
obj = argv[0];
- return rb_funcall_passing_block_with_refinements(obj, (ID) memo->u1.id,
- argc - 1, argv + 1,
- memo->u2.value);
+ return rb_funcall_passing_block(obj, (ID)sym, argc - 1, argv + 1);
}
/*
@@ -7893,32 +7889,25 @@ sym_to_proc(VALUE sym)
VALUE proc;
long id, index;
VALUE *aryp;
- const NODE *cref = rb_vm_cref();
+
+ if (!sym_proc_cache) {
+ sym_proc_cache = rb_ary_tmp_new(SYM_PROC_CACHE_SIZE * 2);
+ rb_gc_register_mark_object(sym_proc_cache);
+ rb_ary_store(sym_proc_cache, SYM_PROC_CACHE_SIZE*2 - 1, Qnil);
+ }
id = SYM2ID(sym);
- if (NIL_P(cref->nd_refinements)) {
- if (!sym_proc_cache) {
- sym_proc_cache = rb_ary_tmp_new(SYM_PROC_CACHE_SIZE * 2);
- rb_gc_register_mark_object(sym_proc_cache);
- rb_ary_store(sym_proc_cache, SYM_PROC_CACHE_SIZE*2 - 1, Qnil);
- }
+ index = (id % SYM_PROC_CACHE_SIZE) << 1;
- index = (id % SYM_PROC_CACHE_SIZE) << 1;
- aryp = RARRAY_PTR(sym_proc_cache);
- if (aryp[index] == sym) {
- return aryp[index + 1];
- }
- else {
- proc = rb_proc_new(sym_call,
- (VALUE) NEW_MEMO(id, Qnil, 0));
- aryp[index] = sym;
- aryp[index + 1] = proc;
- return proc;
- }
+ aryp = RARRAY_PTR(sym_proc_cache);
+ if (aryp[index] == sym) {
+ return aryp[index + 1];
}
else {
- return rb_proc_new(sym_call,
- (VALUE) NEW_MEMO(id, cref->nd_refinements, 0));
+ proc = rb_proc_new(sym_call, (VALUE)id);
+ aryp[index] = sym;
+ aryp[index + 1] = proc;
+ return proc;
}
}