From 2fa4a55e80ceb93ea51d5d3360a614de47894595 Mon Sep 17 00:00:00 2001 From: "Yukihiro \"Matz\" Matsumoto" Date: Fri, 13 Sep 2019 09:21:16 +0900 Subject: Replace `loop` method with `while true` loop to gain performance. --- mrbgems/mruby-enumerator/mrblib/enumerator.rb | 8 ++++++-- 1 file 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 -- cgit v1.2.3