Skip to content

Commit

Permalink
fix: use Map for decorationDestroyedSubscriptions
Browse files Browse the repository at this point in the history
  • Loading branch information
aminya committed Dec 29, 2020
1 parent 9879ab5 commit 661d190
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions lib/mixins/decoration-management.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ export default class DecorationManagement {
* @type {Object}
* @access private
*/
this.decorationDestroyedSubscriptions = {}
this.decorationDestroyedSubscriptions = new Map()
}

/**
Expand Down Expand Up @@ -409,10 +409,10 @@ export default class DecorationManagement {
}))
}

this.decorationDestroyedSubscriptions[decoration.id] =
this.decorationDestroyedSubscriptions.set(decoration.id,
decoration.onDidDestroy(() => {
this.removeDecoration(decoration)
})
}))

this.emitDecorationChanges(type, decoration)
this.emitter.emit('did-add-decoration', {
Expand Down Expand Up @@ -529,11 +529,11 @@ export default class DecorationManagement {
subscription = this.decorationUpdatedSubscriptions.get(decoration.id)
if (subscription != null) { subscription.dispose() }

subscription = this.decorationDestroyedSubscriptions[decoration.id]
subscription = this.decorationDestroyedSubscriptions.get(decoration.id)
if (subscription != null) { subscription.dispose() }

this.decorationUpdatedSubscriptions.delete(decoration.id)
delete this.decorationDestroyedSubscriptions[decoration.id]
this.decorationDestroyedSubscriptions.delete(decoration.id)

const decorations = this.decorationsByMarkerId.get(marker.id)
if (!decorations) { return }
Expand Down Expand Up @@ -619,8 +619,9 @@ export default class DecorationManagement {
decoration.dispose()
}

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

const decorationsByIdValues = this.decorationsById.values()
Expand All @@ -633,6 +634,6 @@ export default class DecorationManagement {
this.decorationMarkerChangedSubscriptions.clear()
this.decorationMarkerDestroyedSubscriptions.clear()
this.decorationUpdatedSubscriptions.clear()
this.decorationDestroyedSubscriptions = {}
this.decorationDestroyedSubscriptions.clear()
}
}

0 comments on commit 661d190

Please sign in to comment.