1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

* 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:
glass 2012-11-02 07:04:39 +00:00
parent fb4e75c1fb
commit da9f6cdcb7
2 changed files with 24 additions and 3 deletions

View file

@ -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

22
array.c
View file

@ -3270,11 +3270,27 @@ static VALUE
recursive_equal(VALUE ary1, VALUE ary2, int recur)
{
long i;
VALUE *p1, *p2;
if (recur) return Qtrue; /* Subtle! */
for (i=0; i<RARRAY_LEN(ary1); i++) {
if (!rb_equal(rb_ary_elt(ary1, i), rb_ary_elt(ary2, i)))
return Qfalse;
p1 = RARRAY_PTR(ary1);
p2 = RARRAY_PTR(ary2);
for (i = 0; i < RARRAY_LEN(ary1); 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;
}