From 89ae7bc7efe9d26862f4f38812fa3a89b3d8da68 Mon Sep 17 00:00:00 2001 From: 1brucben <1benjbruce@gmail.com> Date: Sat, 19 Apr 2025 11:27:31 +0200 Subject: [PATCH] Optimize attack logic by reducing redundant neighbors() and owner() calls --- src/core/execution/AttackExecution.ts | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/core/execution/AttackExecution.ts b/src/core/execution/AttackExecution.ts index f656b5849..eebd1c1d1 100644 --- a/src/core/execution/AttackExecution.ts +++ b/src/core/execution/AttackExecution.ts @@ -240,9 +240,10 @@ export class AttackExecution implements Execution { const fallbackTiles: { tile: TileRef; weight: number }[] = []; const validTiles = this.toConquer.filter((tile) => { - const onBorder = this.mg - .neighbors(tile) - .some((t) => this.mg.owner(t) === this._owner); + const neighbors = this.mg.neighbors(tile); + const onBorder = neighbors.some( + (t) => this.mg.owner(t) === this._owner, + ); return this.mg.owner(tile) === this.target && onBorder; }); if (validTiles.length === 0) {