aboutsummaryrefslogtreecommitdiffstats
path: root/array.c
diff options
context:
space:
mode:
authorshyouhei <shyouhei@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-04-20 10:32:08 +0000
committershyouhei <shyouhei@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-04-20 10:32:08 +0000
commitfbd29d01879cab2c5e4c6e9b8bf7acad00f74a43 (patch)
treef569b74f83a4e44e1a831b5123a700a2d31db9c1 /array.c
parent1d2aff38fc8deb0795951dc2ee92e2895b5867ee (diff)
downloadruby-fbd29d01879cab2c5e4c6e9b8bf7acad00f74a43.tar.gz
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
Diffstat (limited to 'array.c')
-rw-r--r--array.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/array.c b/array.c
index 8e24da2ce6..e21c01194c 100644
--- a/array.c
+++ b/array.c
@@ -515,11 +515,11 @@ 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;
- ary = rb_ary_new2(n);
+ ary = ary_new(klass, n);
if (n > 0 && elts) {
ary_memcpy(ary, 0, n, elts);
ARY_SET_LEN(ary, n);
@@ -529,6 +529,12 @@ rb_ary_new_from_values(long n, const VALUE *elts)
}
VALUE
+rb_ary_new_from_values(long n, const VALUE *elts)
+{
+ return rb_ary_tmp_new_from_values(rb_cArray, n, elts);
+}
+
+VALUE
rb_ary_tmp_new(long capa)
{
return ary_new(0, capa);