refactor torexp to use routine in array.c
Found a part where copy&paste can be eliminated. Reduces vm_exec_core from 26,228 bytes to 26,176 bytes in size on my machine. I believe it does not affect any runtime performance. ---- * array.c (rb_ary_tmp_new_from_values): extend existing rb_ary_new_from_values function so that it can take additional value for klass. * array.c (rb_ary_new_from_values): use the new function. * insns.def (toregexp): ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58416 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
6a08beef51
commit
5069122ab6
10
array.c
10
array.c
@ -515,11 +515,11 @@ VALUE
|
|||||||
}
|
}
|
||||||
|
|
||||||
VALUE
|
VALUE
|
||||||
rb_ary_new_from_values(long n, const VALUE *elts)
|
rb_ary_tmp_new_from_values(VALUE klass, long n, const VALUE *elts)
|
||||||
{
|
{
|
||||||
VALUE ary;
|
VALUE ary;
|
||||||
|
|
||||||
ary = rb_ary_new2(n);
|
ary = ary_new(klass, n);
|
||||||
if (n > 0 && elts) {
|
if (n > 0 && elts) {
|
||||||
ary_memcpy(ary, 0, n, elts);
|
ary_memcpy(ary, 0, n, elts);
|
||||||
ARY_SET_LEN(ary, n);
|
ARY_SET_LEN(ary, n);
|
||||||
@ -528,6 +528,12 @@ rb_ary_new_from_values(long n, const VALUE *elts)
|
|||||||
return ary;
|
return ary;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
VALUE
|
||||||
|
rb_ary_new_from_values(long n, const VALUE *elts)
|
||||||
|
{
|
||||||
|
return rb_ary_tmp_new_from_values(rb_cArray, n, elts);
|
||||||
|
}
|
||||||
|
|
||||||
VALUE
|
VALUE
|
||||||
rb_ary_tmp_new(long capa)
|
rb_ary_tmp_new(long capa)
|
||||||
{
|
{
|
||||||
|
@ -388,11 +388,8 @@ toregexp
|
|||||||
(VALUE val) // inc += 1 - cnt;
|
(VALUE val) // inc += 1 - cnt;
|
||||||
{
|
{
|
||||||
VALUE rb_reg_new_ary(VALUE ary, int options);
|
VALUE rb_reg_new_ary(VALUE ary, int options);
|
||||||
rb_num_t i;
|
VALUE rb_ary_tmp_new_from_values(VALUE, long, const VALUE *);
|
||||||
const VALUE ary = rb_ary_tmp_new(cnt);
|
const VALUE ary = rb_ary_tmp_new_from_values(0, cnt, STACK_ADDR_FROM_TOP(cnt));
|
||||||
for (i = 0; i < cnt; i++) {
|
|
||||||
rb_ary_store(ary, cnt-i-1, TOPN(i));
|
|
||||||
}
|
|
||||||
POPN(cnt);
|
POPN(cnt);
|
||||||
val = rb_reg_new_ary(ary, (int)opt);
|
val = rb_reg_new_ary(ary, (int)opt);
|
||||||
rb_ary_clear(ary);
|
rb_ary_clear(ary);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user