Skip to content

Commit

Permalink
fix: map existence check: use undefined compare
Browse files Browse the repository at this point in the history
exact compare with undefined instead of truthy/null check is 12% faster
https://jsbench.me/q9kja8u4c2/2
  • Loading branch information
aminya committed Dec 29, 2020
1 parent 661d190 commit ec8480a
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions lib/mixins/decoration-management.js
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ export default class DecorationManagement {
const marker = markers[i]
const decorations = this.decorationsByMarkerId.get(marker.id)

if (decorations != null) {
if (decorations !== undefined) {
decorationsByMarkerId[marker.id] = decorations
}
}
Expand Down Expand Up @@ -353,7 +353,7 @@ export default class DecorationManagement {

this.invalidateDecorationForScreenRowsCache()

if (decorations != null) {
if (decorations !== undefined) {
for (let i = 0, len = decorations.length; i < len; i++) {
const decoration = decorations[i]
this.emitter.emit('did-change-decoration', {
Expand Down Expand Up @@ -527,16 +527,16 @@ export default class DecorationManagement {
this.decorationsById.delete(decoration.id)

subscription = this.decorationUpdatedSubscriptions.get(decoration.id)
if (subscription != null) { subscription.dispose() }
if (subscription !== undefined) { subscription.dispose() }

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

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

const decorations = this.decorationsByMarkerId.get(marker.id)
if (!decorations) { return }
if (decorations === undefined) { return }

this.emitDecorationChanges(decoration.getProperties().type, decoration)

Expand Down Expand Up @@ -566,7 +566,7 @@ export default class DecorationManagement {
if (marker == null) { return }

const decorations = this.decorationsByMarkerId.get(marker.id)
if (!decorations) { return }
if (decorations === undefined) { return }

for (let i = 0, len = decorations.length; i < len; i++) {
const decoration = decorations[i]
Expand Down

0 comments on commit ec8480a

Please sign in to comment.