Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit aecdaa2

Browse files
committed
Avoid unnecessary object allocation
Idea from nobu.
1 parent 952154d commit aecdaa2

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

lib/timeout.rb

+2-3
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,8 @@ class Error < RuntimeError
3232
def self.catch(*args)
3333
exc = new(*args)
3434
exc.instance_variable_set(:@thread, Thread.current)
35-
catch_value = Object.new
36-
exc.instance_variable_set(:@catch_value, catch_value)
37-
::Kernel.catch(catch_value) {yield exc}
35+
exc.instance_variable_set(:@catch_value, exc)
36+
::Kernel.catch(exc) {yield exc}
3837
end
3938

4039
def exception(*)

0 commit comments

Comments
 (0)