diff options
author | Yusuke Endoh <mame@ruby-lang.org> | 2019-09-07 22:08:39 +0900 |
---|---|---|
committer | Yusuke Endoh <mame@ruby-lang.org> | 2019-09-07 22:08:39 +0900 |
commit | 8c908c989077c74eed26e02912b98362e509b8a3 (patch) | |
tree | de46c4b622104a1e560f2c3cd1f1736ede552efd /vm_exec.h | |
parent | 07876bf6dbdab5a8a633173f91ee1603d617afb0 (diff) | |
download | ruby-8c908c989077c74eed26e02912b98362e509b8a3.tar.gz |
compile.c (compile_array): rewrite the compilation algorithm
The original code looks unnecessarily complicated (to me).
Also, it creates a pre-allocated array only for the prefix of the array.
The new code optimizes not only the prefix but also the subsequence that
is longer than 0x40 elements.
# not optimized
10000000.times { [1+1, 1,2,3,4,...,63] } # 2.12 sec.
# (1+1; push 1; push 2; ...; puts 63; newarray 64; concatarray)
# optimized
10000000.times { [1+1, 1,2,3,4,...,63,64] } # 1.46 sec.
# (1+1; newarray 1; putobject [1,2,3,...,64]; concatarray)
Diffstat (limited to 'vm_exec.h')
0 files changed, 0 insertions, 0 deletions