mirror of
https://github.com/atom/atom.git
synced 2026-02-11 07:05:11 -05:00
Replace layerUpdateDisposablesByLayerId with a weak map keyed by layer
This commit is contained in:
committed by
Antonio Scandurra
parent
a1faf66a85
commit
69d5b63e9d
@@ -13,7 +13,7 @@ class DecorationManager {
|
||||
this.overlayDecorations = new Set()
|
||||
this.layerDecorationsByMarkerLayer = new Map()
|
||||
this.decorationCountsByLayer = new Map()
|
||||
this.layerUpdateDisposablesByLayerId = {}
|
||||
this.layerUpdateDisposablesByLayer = new WeakMap()
|
||||
}
|
||||
|
||||
observeDecorations (callback) {
|
||||
@@ -234,16 +234,15 @@ class DecorationManager {
|
||||
const newCount = (this.decorationCountsByLayer.get(layer) || 0) + 1
|
||||
this.decorationCountsByLayer.set(layer, newCount)
|
||||
if (newCount === 1) {
|
||||
this.layerUpdateDisposablesByLayerId[layer.id] = layer.onDidUpdate(this.emitDidUpdateDecorations.bind(this))
|
||||
this.layerUpdateDisposablesByLayer.set(layer, layer.onDidUpdate(this.emitDidUpdateDecorations.bind(this)))
|
||||
}
|
||||
}
|
||||
|
||||
unobserveDecoratedLayer (layer) {
|
||||
const newCount = this.decorationCountsByLayer.get(layer) - 1
|
||||
if (newCount === 0) {
|
||||
this.layerUpdateDisposablesByLayerId[layer.id].dispose()
|
||||
this.layerUpdateDisposablesByLayer.get(layer).dispose()
|
||||
this.decorationCountsByLayer.delete(layer)
|
||||
delete this.layerUpdateDisposablesByLayerId[layer.id]
|
||||
} else {
|
||||
this.decorationCountsByLayer.set(layer, newCount)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user