diff options
| author | Ryan Scott Lewis <[email protected]> | 2012-12-19 06:02:15 -0500 |
|---|---|---|
| committer | Ryan Scott Lewis <[email protected]> | 2012-12-19 06:02:15 -0500 |
| commit | 6a450a6bda0d6a3d82821a2adf9e6e2933bab86f (patch) | |
| tree | d7089e3237e6994d7c3b982e44dda8b408838793 /mrblib/array.rb | |
| parent | 2a49cd176e4046cf08cd6cc1350216031e4d847b (diff) | |
| download | mruby-6a450a6bda0d6a3d82821a2adf9e6e2933bab86f.tar.gz mruby-6a450a6bda0d6a3d82821a2adf9e6e2933bab86f.zip | |
Update Array#each to be slightly faster.
Diffstat (limited to 'mrblib/array.rb')
| -rw-r--r-- | mrblib/array.rb | 8 |
1 files changed, 3 insertions, 5 deletions
diff --git a/mrblib/array.rb b/mrblib/array.rb index 50f851fd2..3dc6b57d1 100644 --- a/mrblib/array.rb +++ b/mrblib/array.rb @@ -10,11 +10,9 @@ class Array # # ISO 15.2.12.5.10 def each(&block) - idx = 0 - while(idx < length) - block.call(self[idx]) - idx += 1 - end + idx, length = -1, self.length-1 + block.call(self[idx += 1]) while(idx < length) + self end |
