secret
Created

  • Download Gist
array.c.diff
Diff
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
diff --git array.c array.c
index b4216ac..fab9b5b 100644
--- array.c
+++ array.c
@@ -1778,8 +1778,7 @@ rb_ary_empty_p(VALUE ary)
VALUE
rb_ary_dup(VALUE ary)
{
- VALUE ary_class = rb_obj_class(ary);
- VALUE dup = ary_new(ary_class ? ary_class : rb_cArray, RARRAY_LEN(ary));
+ VALUE dup = rb_ary_new2(RARRAY_LEN(ary));
MEMCPY(RARRAY_PTR(dup), RARRAY_PTR(ary), VALUE, RARRAY_LEN(ary));
ARY_SET_LEN(dup, RARRAY_LEN(ary));
return dup;
@@ -4009,8 +4008,11 @@ rb_ary_uniq(VALUE ary)
VALUE hash, uniq, v;
long i;
- if (RARRAY_LEN(ary) <= 1)
- return rb_ary_dup(ary);
+ if (RARRAY_LEN(ary) <= 1) {
+ uniq = rb_ary_dup(ary);
+ RBASIC(uniq)->klass = rb_obj_class(ary);
+ return uniq;
+ }
if (rb_block_given_p()) {
hash = ary_make_hash_by(ary);
uniq = ary_new(rb_obj_class(ary), RHASH_SIZE(hash));

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.