mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* array.c (rb_ary_permutation, rb_ary_combination, rb_ary_product):
hide internal buffer objects. [ruby-dev:31982] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@13664 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
51baef22a6
commit
81b55c0ff3
2 changed files with 16 additions and 1 deletions
|
@ -1,3 +1,8 @@
|
||||||
|
Tue Oct 9 16:33:32 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||||
|
|
||||||
|
* array.c (rb_ary_permutation, rb_ary_combination, rb_ary_product):
|
||||||
|
hide internal buffer objects. [ruby-dev:31982]
|
||||||
|
|
||||||
Tue Oct 9 16:00:32 2007 NAKAMURA Usaku <usa@ruby-lang.org>
|
Tue Oct 9 16:00:32 2007 NAKAMURA Usaku <usa@ruby-lang.org>
|
||||||
|
|
||||||
* parse.y (parser_read_escape, parser_tokadd_escape): check code range.
|
* parse.y (parser_read_escape, parser_tokadd_escape): check code range.
|
||||||
|
|
12
array.c
12
array.c
|
@ -231,11 +231,13 @@ to_ary(VALUE ary)
|
||||||
return rb_convert_type(ary, T_ARRAY, "Array", "to_ary");
|
return rb_convert_type(ary, T_ARRAY, "Array", "to_ary");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if 0
|
||||||
static VALUE
|
static VALUE
|
||||||
to_a(VALUE ary)
|
to_a(VALUE ary)
|
||||||
{
|
{
|
||||||
return rb_convert_type(ary, T_ARRAY, "Array", "to_a");
|
return rb_convert_type(ary, T_ARRAY, "Array", "to_a");
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
VALUE
|
VALUE
|
||||||
rb_check_array_type(VALUE ary)
|
rb_check_array_type(VALUE ary)
|
||||||
|
@ -690,7 +692,7 @@ rb_ary_subseq(VALUE ary, long beg, long len)
|
||||||
if (len == 0) return ary_new(klass, 0);
|
if (len == 0) return ary_new(klass, 0);
|
||||||
|
|
||||||
shared = ary_make_shared(ary);
|
shared = ary_make_shared(ary);
|
||||||
ptr = RARRAY_PTR(ary);
|
ptr = RARRAY_PTR(ary);
|
||||||
ary2 = ary_alloc(klass);
|
ary2 = ary_alloc(klass);
|
||||||
RARRAY(ary2)->ptr = ptr + beg;
|
RARRAY(ary2)->ptr = ptr + beg;
|
||||||
RARRAY(ary2)->len = len;
|
RARRAY(ary2)->len = len;
|
||||||
|
@ -3041,6 +3043,9 @@ rb_ary_permutation(VALUE ary, VALUE num)
|
||||||
long *p = (long*)RSTRING_PTR(t0); /* array indexes of current permutation */
|
long *p = (long*)RSTRING_PTR(t0); /* array indexes of current permutation */
|
||||||
volatile VALUE t1 = rb_str_new(0, n*sizeof(int));
|
volatile VALUE t1 = rb_str_new(0, n*sizeof(int));
|
||||||
int *used = (int*)RSTRING_PTR(t1); /* booleans: which indexes are already used */
|
int *used = (int*)RSTRING_PTR(t1); /* booleans: which indexes are already used */
|
||||||
|
|
||||||
|
RBASIC(t0)->klass = 0;
|
||||||
|
RBASIC(t1)->klass = 0;
|
||||||
ary = rb_ary_dup(ary); /* private defensive copy of ary */
|
ary = rb_ary_dup(ary); /* private defensive copy of ary */
|
||||||
|
|
||||||
for(i = 0; i < n; i++) used[i] = 0; /* initialize array */
|
for(i = 0; i < n; i++) used[i] = 0; /* initialize array */
|
||||||
|
@ -3116,6 +3121,8 @@ rb_ary_combination(VALUE ary, VALUE num)
|
||||||
VALUE *chosen = RARRAY_PTR(cc);
|
VALUE *chosen = RARRAY_PTR(cc);
|
||||||
long lev = 0;
|
long lev = 0;
|
||||||
|
|
||||||
|
RBASIC(tmp)->klass = 0;
|
||||||
|
RBASIC(cc)->klass = 0;
|
||||||
MEMZERO(stack, long, n);
|
MEMZERO(stack, long, n);
|
||||||
stack[0] = -1;
|
stack[0] = -1;
|
||||||
for (i = 0; i < nlen; i++) {
|
for (i = 0; i < nlen; i++) {
|
||||||
|
@ -3160,6 +3167,9 @@ rb_ary_product(int argc, VALUE *argv, VALUE ary)
|
||||||
long i,j;
|
long i,j;
|
||||||
long resultlen = 1;
|
long resultlen = 1;
|
||||||
|
|
||||||
|
RBASIC(t0)->klass = 0;
|
||||||
|
RBASIC(t1)->klass = 0;
|
||||||
|
|
||||||
/* initialize the arrays of arrays */
|
/* initialize the arrays of arrays */
|
||||||
arrays[0] = ary;
|
arrays[0] = ary;
|
||||||
for(i = 1; i < n; i++) arrays[i] = argv[i-1];
|
for(i = 1; i < n; i++) arrays[i] = argv[i-1];
|
||||||
|
|
Loading…
Reference in a new issue