diff options
author | yugui <yugui@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2010-09-29 12:25:24 +0000 |
---|---|---|
committer | yugui <yugui@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2010-09-29 12:25:24 +0000 |
commit | 2fd98b1d3e3ff35bc6300404698cc9af98bc26d1 (patch) | |
tree | 6d50e0f26f791d60a53aa735835d584133dccf0a /array.c | |
parent | 15fd502f5369ad1e9c801287445b39a6316b2fbd (diff) |
merges r29044 from trunk into ruby_1_9_2.
--
* array.c (rb_ary_permutation, rb_ary_repeated_permutation, rb_ary_repeated_combination, rb_ary_product): use ary_make_shared_copy instead of ary_make_substitution. [ruby-dev:42067] [Bug #3708]
* test/ruby/test_array.rb (test_product, test_repeated_permutation, test_repeated_combination): append assertions against [Bug #3708].
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_9_2@29370 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'array.c')
-rw-r--r-- | array.c | 8 |
1 files changed, 4 insertions, 4 deletions
@@ -4004,7 +4004,7 @@ rb_ary_permutation(int argc, VALUE *argv, VALUE ary) long *p = (long*)RSTRING_PTR(t0); volatile VALUE t1 = tmpbuf(n,sizeof(char)); char *used = (char*)RSTRING_PTR(t1); - VALUE ary0 = ary_make_substitution(ary); /* private defensive copy of ary */ + VALUE ary0 = ary_make_shared_copy(ary); /* private defensive copy of ary */ RBASIC(ary0)->klass = 0; MEMZERO(used, char, n); /* initialize array */ @@ -4174,7 +4174,7 @@ rb_ary_repeated_permutation(VALUE ary, VALUE num) else { /* this is the general case */ volatile VALUE t0 = tmpbuf(r, sizeof(long)); long *p = (long*)RSTRING_PTR(t0); - VALUE ary0 = ary_make_substitution(ary); /* private defensive copy of ary */ + VALUE ary0 = ary_make_shared_copy(ary); /* private defensive copy of ary */ RBASIC(ary0)->klass = 0; rpermute0(n, r, p, 0, ary0); /* compute and yield repeated permutations */ @@ -4260,7 +4260,7 @@ rb_ary_repeated_combination(VALUE ary, VALUE num) else { volatile VALUE t0 = tmpbuf(n, sizeof(long)); long *p = (long*)RSTRING_PTR(t0); - VALUE ary0 = ary_make_substitution(ary); /* private defensive copy of ary */ + VALUE ary0 = ary_make_shared_copy(ary); /* private defensive copy of ary */ RBASIC(ary0)->klass = 0; rcombinate0(len, n, p, 0, n, ary0); /* compute and yield repeated combinations */ @@ -4319,7 +4319,7 @@ rb_ary_product(int argc, VALUE *argv, VALUE ary) /* Make defensive copies of arrays; exit if any is empty */ for (i = 0; i < n; i++) { if (RARRAY_LEN(arrays[i]) == 0) goto done; - arrays[i] = ary_make_substitution(arrays[i]); + arrays[i] = ary_make_shared_copy(arrays[i]); } } else { |