File tree Expand file tree Collapse file tree 2 files changed +14
-4
lines changed Expand file tree Collapse file tree 2 files changed +14
-4
lines changed Original file line number Diff line number Diff line change @@ -20,11 +20,11 @@ def execute(type = nil, arg = nil)
20
20
when :on
21
21
IRB . conf [ :MEASURE ] = true
22
22
added = IRB . set_measure_callback ( type , arg )
23
- puts "#{ added [ 0 ] } is added."
23
+ puts "#{ added [ 0 ] } is added." if added
24
24
else
25
25
IRB . conf [ :MEASURE ] = true
26
26
added = IRB . set_measure_callback ( type , arg )
27
- puts "#{ added [ 0 ] } is added."
27
+ puts "#{ added [ 0 ] } is added." if added
28
28
end
29
29
nil
30
30
end
Original file line number Diff line number Diff line change @@ -158,8 +158,18 @@ def IRB.set_measure_callback(type = nil, arg = nil)
158
158
else
159
159
added = [ :TIME , IRB . conf [ :MEASURE_PROC ] [ :TIME ] , arg ]
160
160
end
161
- IRB . conf [ :MEASURE_CALLBACKS ] << added if added
162
- added
161
+ if added
162
+ found = IRB . conf [ :MEASURE_CALLBACKS ] . find { |m | m [ 0 ] == added [ 0 ] && m [ 2 ] == added [ 2 ] }
163
+ if found
164
+ # already added
165
+ nil
166
+ else
167
+ IRB . conf [ :MEASURE_CALLBACKS ] << added if added
168
+ added
169
+ end
170
+ else
171
+ nil
172
+ end
163
173
end
164
174
165
175
def IRB . unset_measure_callback ( type = nil )
You can’t perform that action at this time.
0 commit comments