mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* parse.y: optimize 'for' statement when one variable given.
* benchmark/bm_loop_for.rb: added. * benchmark/bm_loop_times.rb: modified. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@19753 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
254937c873
commit
3f710785f0
4 changed files with 29 additions and 7 deletions
|
@ -1,3 +1,11 @@
|
|||
Sat Oct 11 03:54:05 2008 Koichi Sasada <ko1@atdot.net>
|
||||
|
||||
* parse.y: optimize 'for' statement when one variable given.
|
||||
|
||||
* benchmark/bm_loop_for.rb: added.
|
||||
|
||||
* benchmark/bm_loop_times.rb: modified.
|
||||
|
||||
Sat Oct 11 12:09:05 2008 James Edward Gray II <jeg2@ruby-lang.org>
|
||||
|
||||
* lib/csv/csv.rb: Added support for Encoding::default_internal.
|
||||
|
|
3
benchmark/bm_loop_for.rb
Normal file
3
benchmark/bm_loop_for.rb
Normal file
|
@ -0,0 +1,3 @@
|
|||
for i in 1..30_000_000
|
||||
#
|
||||
end
|
|
@ -1 +1 @@
|
|||
30000000.times{|e|}
|
||||
30_000_000.times{|e|}
|
||||
|
|
23
parse.y
23
parse.y
|
@ -2772,16 +2772,27 @@ primary : literal
|
|||
NEW_CALL(NEW_CALL(NEW_DVAR(id), rb_intern("[]"), zero),
|
||||
rb_intern("kind_of?"), NEW_LIST(NEW_LIT(rb_cArray))),
|
||||
0),
|
||||
NEW_DASGN_CURR(id,
|
||||
NEW_CALL(NEW_DVAR(id), rb_intern("[]"), zero)),
|
||||
0),
|
||||
NEW_DASGN_CURR(id,
|
||||
NEW_CALL(NEW_DVAR(id), rb_intern("[]"), zero)),
|
||||
0),
|
||||
node_assign($2, NEW_DVAR(id)));
|
||||
|
||||
args = new_args(m, 0, id, 0, 0);
|
||||
}
|
||||
else {
|
||||
m->nd_next = node_assign(NEW_MASGN(NEW_LIST($2), 0), NEW_DVAR(id));
|
||||
if (nd_type($2) == NODE_LASGN ||
|
||||
nd_type($2) == NODE_DASGN ||
|
||||
nd_type($2) == NODE_DASGN_CURR) {
|
||||
$2->nd_value = NEW_DVAR(id);
|
||||
m->nd_plen = 1;
|
||||
m->nd_next = $2;
|
||||
args = new_args(m, 0, 0, 0, 0);
|
||||
}
|
||||
else {
|
||||
m->nd_next = node_assign(NEW_MASGN(NEW_LIST($2), 0), NEW_DVAR(id));
|
||||
args = new_args(m, 0, id, 0, 0);
|
||||
}
|
||||
}
|
||||
|
||||
args = new_args(m, 0, id, 0, 0);
|
||||
scope = NEW_NODE(NODE_SCOPE, tbl, $8, args);
|
||||
tbl[0] = 1; tbl[1] = id;
|
||||
$$ = NEW_FOR(0, $5, scope);
|
||||
|
|
Loading…
Add table
Reference in a new issue