mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* thread.c (recursive_pop): use object ID.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@14128 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
2257138aa5
commit
62c94002ef
2 changed files with 9 additions and 6 deletions
|
@ -1,4 +1,4 @@
|
||||||
Fri Dec 7 12:27:18 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
Fri Dec 7 15:04:01 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||||
|
|
||||||
* array.c (flatten): some performance improvements, based on a patch
|
* array.c (flatten): some performance improvements, based on a patch
|
||||||
from Yusuke ENDOH <mame AT tsg.ne.jp> in [ruby-core:13877].
|
from Yusuke ENDOH <mame AT tsg.ne.jp> in [ruby-core:13877].
|
||||||
|
@ -7,6 +7,8 @@ Fri Dec 7 12:27:18 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||||
* thread.c (rb_exec_recursive): use Hash instead of Array for
|
* thread.c (rb_exec_recursive): use Hash instead of Array for
|
||||||
performance improvement. [ruby-core:13898]
|
performance improvement. [ruby-core:13898]
|
||||||
|
|
||||||
|
* thread.c (recursive_pop): use object ID.
|
||||||
|
|
||||||
Thu Dec 6 19:52:50 2007 Yukihiro Matsumoto <matz@ruby-lang.org>
|
Thu Dec 6 19:52:50 2007 Yukihiro Matsumoto <matz@ruby-lang.org>
|
||||||
|
|
||||||
* parse.y (arg): typo fixed ("!" -> "|") in the ripper code.
|
* parse.y (arg): typo fixed ("!" -> "|") in the ripper code.
|
||||||
|
|
11
thread.c
11
thread.c
|
@ -2593,7 +2593,7 @@ recursive_check(VALUE hash, VALUE obj)
|
||||||
|
|
||||||
if (NIL_P(list) || TYPE(list) != T_HASH)
|
if (NIL_P(list) || TYPE(list) != T_HASH)
|
||||||
return Qfalse;
|
return Qfalse;
|
||||||
if (NIL_P(rb_hash_lookup(list, rb_obj_id(obj))))
|
if (NIL_P(rb_hash_lookup(list, obj)))
|
||||||
return Qfalse;
|
return Qfalse;
|
||||||
return Qtrue;
|
return Qtrue;
|
||||||
}
|
}
|
||||||
|
@ -2617,7 +2617,7 @@ recursive_push(VALUE hash, VALUE obj)
|
||||||
list = rb_hash_new();
|
list = rb_hash_new();
|
||||||
rb_hash_aset(hash, sym, list);
|
rb_hash_aset(hash, sym, list);
|
||||||
}
|
}
|
||||||
rb_hash_aset(list, rb_obj_id(obj), Qtrue);
|
rb_hash_aset(list, obj, Qtrue);
|
||||||
return hash;
|
return hash;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2650,21 +2650,22 @@ VALUE
|
||||||
rb_exec_recursive(VALUE (*func) (VALUE, VALUE, int), VALUE obj, VALUE arg)
|
rb_exec_recursive(VALUE (*func) (VALUE, VALUE, int), VALUE obj, VALUE arg)
|
||||||
{
|
{
|
||||||
VALUE hash = rb_thread_local_aref(rb_thread_current(), recursive_key);
|
VALUE hash = rb_thread_local_aref(rb_thread_current(), recursive_key);
|
||||||
|
VALUE objid = rb_obj_id(obj);
|
||||||
|
|
||||||
if (recursive_check(hash, obj)) {
|
if (recursive_check(hash, objid)) {
|
||||||
return (*func) (obj, arg, Qtrue);
|
return (*func) (obj, arg, Qtrue);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
VALUE result = Qundef;
|
VALUE result = Qundef;
|
||||||
int state;
|
int state;
|
||||||
|
|
||||||
hash = recursive_push(hash, obj);
|
hash = recursive_push(hash, objid);
|
||||||
PUSH_TAG();
|
PUSH_TAG();
|
||||||
if ((state = EXEC_TAG()) == 0) {
|
if ((state = EXEC_TAG()) == 0) {
|
||||||
result = (*func) (obj, arg, Qfalse);
|
result = (*func) (obj, arg, Qfalse);
|
||||||
}
|
}
|
||||||
POP_TAG();
|
POP_TAG();
|
||||||
recursive_pop(hash, obj);
|
recursive_pop(hash, objid);
|
||||||
if (state)
|
if (state)
|
||||||
JUMP_TAG(state);
|
JUMP_TAG(state);
|
||||||
return result;
|
return result;
|
||||||
|
|
Loading…
Reference in a new issue