mirror of
https://github.com/rubyjs/therubyracer
synced 2023-03-27 23:21:42 -04:00
29 lines
467 B
Ruby
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
|