Skip to content

Commit f2e6515

Browse files
committed
fix: use Map for decorationMarkerDestroyedSubscriptions
1 parent 6a0d612 commit f2e6515

File tree

1 file changed

+10
-9
lines changed

1 file changed

+10
-9
lines changed

lib/mixins/decoration-management.js

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ export default class DecorationManagement {
5151
* @type {Object}
5252
* @access private
5353
*/
54-
this.decorationMarkerDestroyedSubscriptions = {}
54+
this.decorationMarkerDestroyedSubscriptions = new Map()
5555
/**
5656
* The subscriptions to the decorations `did-change-properties` event
5757
* indexed using the decoration id.
@@ -338,11 +338,11 @@ export default class DecorationManagement {
338338
decorationParams.scope = `.minimap .${cls}`
339339
}
340340

341-
if (this.decorationMarkerDestroyedSubscriptions[id] == null) {
342-
this.decorationMarkerDestroyedSubscriptions[id] =
341+
if (!this.decorationMarkerDestroyedSubscriptions.has(id)) {
342+
this.decorationMarkerDestroyedSubscriptions.set(id,
343343
marker.onDidDestroy(() => {
344344
this.removeAllDecorationsForMarker(marker)
345-
})
345+
}))
346346
}
347347

348348
if (!this.decorationMarkerChangedSubscriptions.has(id)) {
@@ -593,11 +593,11 @@ export default class DecorationManagement {
593593
if (marker == null) { return }
594594

595595
this.decorationMarkerChangedSubscriptions.get(marker.id).dispose()
596-
this.decorationMarkerDestroyedSubscriptions[marker.id].dispose()
596+
this.decorationMarkerDestroyedSubscriptions.get(marker.id).dispose()
597597

598598
this.decorationsByMarkerId.delete(marker.id)
599599
this.decorationMarkerChangedSubscriptions.delete(marker.id)
600-
delete this.decorationMarkerDestroyedSubscriptions[marker.id]
600+
this.decorationMarkerDestroyedSubscriptions.delete(marker.id)
601601
}
602602

603603
/**
@@ -609,8 +609,9 @@ export default class DecorationManagement {
609609
decoration.dispose()
610610
}
611611

612-
for (const id in this.decorationMarkerDestroyedSubscriptions) {
613-
this.decorationMarkerDestroyedSubscriptions[id].dispose()
612+
const decorationMarkerDestroyedSubscriptionsValues = this.decorationMarkerDestroyedSubscriptions.values()
613+
for (const decoration of decorationMarkerDestroyedSubscriptionsValues) {
614+
decoration.dispose()
614615
}
615616

616617
for (const id in this.decorationUpdatedSubscriptions) {
@@ -629,7 +630,7 @@ export default class DecorationManagement {
629630
this.decorationsById.clear()
630631
this.decorationsByMarkerId.clear()
631632
this.decorationMarkerChangedSubscriptions.clear()
632-
this.decorationMarkerDestroyedSubscriptions = {}
633+
this.decorationMarkerDestroyedSubscriptions.clear()
633634
this.decorationUpdatedSubscriptions = {}
634635
this.decorationDestroyedSubscriptions = {}
635636
}

0 commit comments

Comments
 (0)