* array.c (recursive_equal): performance improvement.
[ruby-dev:45412] [Feature #6177] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37420 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
fb4e75c1fb
commit
da9f6cdcb7
@ -1,3 +1,8 @@
|
||||
Fri Nov 2 14:52:52 2012 Masaki Matsushita <glass.saga@gmail.com>
|
||||
|
||||
* array.c (recursive_equal): performance improvement.
|
||||
[ruby-dev:45412] [Feature #6177]
|
||||
|
||||
Fri Nov 2 14:47:53 2012 Shugo Maeda <shugo@ruby-lang.org>
|
||||
|
||||
* string.c (sym_to_proc, sym_call): A Proc created by Symbol#to_proc
|
||||
|
18
array.c
18
array.c
@ -3270,11 +3270,27 @@ static VALUE
|
||||
recursive_equal(VALUE ary1, VALUE ary2, int recur)
|
||||
{
|
||||
long i;
|
||||
VALUE *p1, *p2;
|
||||
|
||||
if (recur) return Qtrue; /* Subtle! */
|
||||
|
||||
p1 = RARRAY_PTR(ary1);
|
||||
p2 = RARRAY_PTR(ary2);
|
||||
|
||||
for (i = 0; i < RARRAY_LEN(ary1); i++) {
|
||||
if (!rb_equal(rb_ary_elt(ary1, i), rb_ary_elt(ary2, i)))
|
||||
if (*p1 != *p2) {
|
||||
if (rb_equal(*p1, *p2)) {
|
||||
if (RARRAY_LEN(ary1) != RARRAY_LEN(ary2))
|
||||
return Qfalse;
|
||||
p1 = RARRAY_PTR(ary1) + i;
|
||||
p2 = RARRAY_PTR(ary2) + i;
|
||||
}
|
||||
else {
|
||||
return Qfalse;
|
||||
}
|
||||
}
|
||||
p1++;
|
||||
p2++;
|
||||
}
|
||||
return Qtrue;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user