Skip to content

Commit

Permalink
fix: use Map for decorationMarkerDestroyedSubscriptions
Browse files Browse the repository at this point in the history
  • Loading branch information
aminya committed Dec 29, 2020
1 parent 6a0d612 commit f2e6515
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions lib/mixins/decoration-management.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ export default class DecorationManagement {
* @type {Object}
* @access private
*/
this.decorationMarkerDestroyedSubscriptions = {}
this.decorationMarkerDestroyedSubscriptions = new Map()
/**
* The subscriptions to the decorations `did-change-properties` event
* indexed using the decoration id.
Expand Down Expand Up @@ -338,11 +338,11 @@ export default class DecorationManagement {
decorationParams.scope = `.minimap .${cls}`
}

if (this.decorationMarkerDestroyedSubscriptions[id] == null) {
this.decorationMarkerDestroyedSubscriptions[id] =
if (!this.decorationMarkerDestroyedSubscriptions.has(id)) {
this.decorationMarkerDestroyedSubscriptions.set(id,
marker.onDidDestroy(() => {
this.removeAllDecorationsForMarker(marker)
})
}))
}

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

this.decorationMarkerChangedSubscriptions.get(marker.id).dispose()
this.decorationMarkerDestroyedSubscriptions[marker.id].dispose()
this.decorationMarkerDestroyedSubscriptions.get(marker.id).dispose()

this.decorationsByMarkerId.delete(marker.id)
this.decorationMarkerChangedSubscriptions.delete(marker.id)
delete this.decorationMarkerDestroyedSubscriptions[marker.id]
this.decorationMarkerDestroyedSubscriptions.delete(marker.id)
}

/**
Expand All @@ -609,8 +609,9 @@ export default class DecorationManagement {
decoration.dispose()
}

for (const id in this.decorationMarkerDestroyedSubscriptions) {
this.decorationMarkerDestroyedSubscriptions[id].dispose()
const decorationMarkerDestroyedSubscriptionsValues = this.decorationMarkerDestroyedSubscriptions.values()
for (const decoration of decorationMarkerDestroyedSubscriptionsValues) {
decoration.dispose()
}

for (const id in this.decorationUpdatedSubscriptions) {
Expand All @@ -629,7 +630,7 @@ export default class DecorationManagement {
this.decorationsById.clear()
this.decorationsByMarkerId.clear()
this.decorationMarkerChangedSubscriptions.clear()
this.decorationMarkerDestroyedSubscriptions = {}
this.decorationMarkerDestroyedSubscriptions.clear()
this.decorationUpdatedSubscriptions = {}
this.decorationDestroyedSubscriptions = {}
}
Expand Down

0 comments on commit f2e6515

Please sign in to comment.