Skip to content

Commit ec8480a

Browse files
committed
fix: map existence check: use undefined compare
exact compare with undefined instead of truthy/null check is 12% faster https://jsbench.me/q9kja8u4c2/2
1 parent 661d190 commit ec8480a

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

lib/mixins/decoration-management.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ export default class DecorationManagement {
189189
const marker = markers[i]
190190
const decorations = this.decorationsByMarkerId.get(marker.id)
191191

192-
if (decorations != null) {
192+
if (decorations !== undefined) {
193193
decorationsByMarkerId[marker.id] = decorations
194194
}
195195
}
@@ -353,7 +353,7 @@ export default class DecorationManagement {
353353

354354
this.invalidateDecorationForScreenRowsCache()
355355

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

529529
subscription = this.decorationUpdatedSubscriptions.get(decoration.id)
530-
if (subscription != null) { subscription.dispose() }
530+
if (subscription !== undefined) { subscription.dispose() }
531531

532532
subscription = this.decorationDestroyedSubscriptions.get(decoration.id)
533-
if (subscription != null) { subscription.dispose() }
533+
if (subscription !== undefined) { subscription.dispose() }
534534

535535
this.decorationUpdatedSubscriptions.delete(decoration.id)
536536
this.decorationDestroyedSubscriptions.delete(decoration.id)
537537

538538
const decorations = this.decorationsByMarkerId.get(marker.id)
539-
if (!decorations) { return }
539+
if (decorations === undefined) { return }
540540

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

@@ -566,7 +566,7 @@ export default class DecorationManagement {
566566
if (marker == null) { return }
567567

568568
const decorations = this.decorationsByMarkerId.get(marker.id)
569-
if (!decorations) { return }
569+
if (decorations === undefined) { return }
570570

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

0 commit comments

Comments
 (0)