1
0
Fork 0
mirror of https://github.com/rubyjs/therubyracer synced 2023-03-27 23:21:42 -04:00
therubyracer/lib/v8/retained_objects.rb
2015-07-06 01:05:37 -05:00

29 lines
467 B
Ruby

module V8
class RetainedObjects
def initialize
@counts = {}
end
def add(object)
if @counts[object]
@counts[object] += 1
else
@counts[object] = 1
end
end
def remove(object)
if count = @counts[object]
if count <= 1
@counts.delete object
else
@counts[object] -= 1
end
end
end
def retaining?(object)
!!@counts[object]
end
end
end