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

* array.c (rb_ary_permutation): hide temporal array.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@20062 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
mame 2008-10-30 12:35:04 +00:00
parent 93fa4cbf3d
commit ea4ae3302d
2 changed files with 6 additions and 0 deletions

View file

@ -1,3 +1,7 @@
Thu Oct 30 21:32:15 2008 Yusuke Endoh <mame@tsg.ne.jp>
* array.c (rb_ary_permutation): hide temporal array.
Thu Oct 30 14:45:45 2008 Martin Duerst <duerst@it.aoyama.ac.jp> Thu Oct 30 14:45:45 2008 Martin Duerst <duerst@it.aoyama.ac.jp>
* enc/trans/single_byte.trans: refactoring to make it easier * enc/trans/single_byte.trans: refactoring to make it easier

View file

@ -3461,12 +3461,14 @@ rb_ary_permutation(int argc, VALUE *argv, VALUE ary)
volatile VALUE t1 = tmpbuf(n,sizeof(int)); volatile VALUE t1 = tmpbuf(n,sizeof(int));
int *used = (int*)RSTRING_PTR(t1); int *used = (int*)RSTRING_PTR(t1);
VALUE ary0 = ary_make_substitution(ary); /* private defensive copy of ary */ VALUE ary0 = ary_make_substitution(ary); /* private defensive copy of ary */
RBASIC(ary0)->klass = 0;
for (i = 0; i < n; i++) used[i] = 0; /* initialize array */ for (i = 0; i < n; i++) used[i] = 0; /* initialize array */
permute0(n, r, p, 0, used, ary0); /* compute and yield permutations */ permute0(n, r, p, 0, used, ary0); /* compute and yield permutations */
RB_GC_GUARD(t0); RB_GC_GUARD(t0);
RB_GC_GUARD(t1); RB_GC_GUARD(t1);
RBASIC(ary0)->klass = rb_cArray;
} }
return ary; return ary;
} }