From 4a5c455c0b8255a66b5ba4d605901416d1f225b3 Mon Sep 17 00:00:00 2001 From: Jonas Jenwald Date: Thu, 30 Apr 2026 12:02:10 +0200 Subject: [PATCH] Shorten how intersectors are added to the grid in the `Intersector` constructor Thanks to modern JavaScript features this code can be simplified a tiny bit. --- src/core/intersector.js | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/src/core/intersector.js b/src/core/intersector.js index 75f8bb43e..687a15249 100644 --- a/src/core/intersector.js +++ b/src/core/intersector.js @@ -192,11 +192,7 @@ class Intersector { const h = Math.floor((iMax - iMin) / STEPS); for (let i = iMin; i <= iMin + h * STEPS; i += STEPS) { for (let j = 0; j <= w; j++) { - let existing = this.#grid[i + j]; - if (!existing) { - this.#grid[i + j] = existing = []; - } - existing.push(intersector); + (this.#grid[i + j] ??= []).push(intersector); } } }