mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
[ruby/irb] Try not to register the exact same measuring method twice
https://github.com/ruby/irb/commit/cc66b5573e
This commit is contained in:
parent
2c752ff930
commit
167dc37632
2 changed files with 14 additions and 4 deletions
|
@ -20,11 +20,11 @@ module IRB
|
|||
when :on
|
||||
IRB.conf[:MEASURE] = true
|
||||
added = IRB.set_measure_callback(type, arg)
|
||||
puts "#{added[0]} is added."
|
||||
puts "#{added[0]} is added." if added
|
||||
else
|
||||
IRB.conf[:MEASURE] = true
|
||||
added = IRB.set_measure_callback(type, arg)
|
||||
puts "#{added[0]} is added."
|
||||
puts "#{added[0]} is added." if added
|
||||
end
|
||||
nil
|
||||
end
|
||||
|
|
|
@ -158,8 +158,18 @@ module IRB # :nodoc:
|
|||
else
|
||||
added = [:TIME, IRB.conf[:MEASURE_PROC][:TIME], arg]
|
||||
end
|
||||
IRB.conf[:MEASURE_CALLBACKS] << added if added
|
||||
added
|
||||
if added
|
||||
found = IRB.conf[:MEASURE_CALLBACKS].find{ |m| m[0] == added[0] && m[2] == added[2] }
|
||||
if found
|
||||
# already added
|
||||
nil
|
||||
else
|
||||
IRB.conf[:MEASURE_CALLBACKS] << added if added
|
||||
added
|
||||
end
|
||||
else
|
||||
nil
|
||||
end
|
||||
end
|
||||
|
||||
def IRB.unset_measure_callback(type = nil)
|
||||
|
|
Loading…
Add table
Reference in a new issue