diff options
| author | Yukihiro "Matz" Matsumoto <[email protected]> | 2019-09-13 09:21:16 +0900 |
|---|---|---|
| committer | Yukihiro "Matz" Matsumoto <[email protected]> | 2019-09-14 09:05:32 +0900 |
| commit | 2fa4a55e80ceb93ea51d5d3360a614de47894595 (patch) | |
| tree | a53df843ed70abf4b594e01177395a7e9d59b59a | |
| parent | 5489fae8f24782336e500efe56ae741c5d924174 (diff) | |
| download | mruby-2fa4a55e80ceb93ea51d5d3360a614de47894595.tar.gz mruby-2fa4a55e80ceb93ea51d5d3360a614de47894595.zip | |
Replace `loop` method with `while true` loop to gain performance.
| -rw-r--r-- | mrbgems/mruby-enumerator/mrblib/enumerator.rb | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/mrbgems/mruby-enumerator/mrblib/enumerator.rb b/mrbgems/mruby-enumerator/mrblib/enumerator.rb index d02caf5a0..ecc3760b0 100644 --- a/mrbgems/mruby-enumerator/mrblib/enumerator.rb +++ b/mrbgems/mruby-enumerator/mrblib/enumerator.rb @@ -587,8 +587,12 @@ class Enumerator val = init y.yield(val) end - loop do - y.yield(val = block.call(val)) + begin + while true + y.yield(val = block.call(val)) + end + rescue StopIteration + # do nothing end end end |
