diff options
| author | Yukihiro "Matz" Matsumoto <[email protected]> | 2012-12-19 03:40:24 -0800 |
|---|---|---|
| committer | Yukihiro "Matz" Matsumoto <[email protected]> | 2012-12-19 03:40:24 -0800 |
| commit | 1184efe62b4fe537df6941fde43cdd56b82490bd (patch) | |
| tree | 38e7764dccebc1432d89b2f4c4cbc23be1c28311 /mrblib/array.rb | |
| parent | 207de4a3b3d1f95cd0ae7d79f06ceb30654b01f5 (diff) | |
| parent | 6a450a6bda0d6a3d82821a2adf9e6e2933bab86f (diff) | |
| download | mruby-1184efe62b4fe537df6941fde43cdd56b82490bd.tar.gz mruby-1184efe62b4fe537df6941fde43cdd56b82490bd.zip | |
Merge pull request #648 from RyanScottLewis/master
Slightly faster Array#each method.
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 |
