From 369483b4ac437f4bb640c73d26434ef00af238d1 Mon Sep 17 00:00:00 2001 From: robert-pitt-foodhub <70318887+robert-pitt-foodhub@users.noreply.github.com> Date: Fri, 16 May 2025 00:07:39 +0100 Subject: [PATCH] =?UTF-8?q?Small=20optimisation=20in=20TerritoryLayer.rend?= =?UTF-8?q?erLayer=20call=20to=20dedupe=20Date.=E2=80=A6=20(#759)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## Description: Small optimisation in TerritoryLayer.renderLayer call to dedupe Date.now() ## Please complete the following: - [-] I have added screenshots for all UI updates - [x] I confirm I have thoroughly tested these changes and take full responsibility for any bugs introduced - [x] I understand that submitting code with bugs that could have been caught through manual testing blocks releases and new features for all contributors ## Please put your Discord username so you can be contacted if a bug or regression is found: N/A Co-authored-by: robertpitt --- src/client/graphics/layers/TerritoryLayer.ts | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/client/graphics/layers/TerritoryLayer.ts b/src/client/graphics/layers/TerritoryLayer.ts index f6906ffb1..d1a008868 100644 --- a/src/client/graphics/layers/TerritoryLayer.ts +++ b/src/client/graphics/layers/TerritoryLayer.ts @@ -186,11 +186,12 @@ export class TerritoryLayer implements Layer { } renderLayer(context: CanvasRenderingContext2D) { + const now = Date.now(); if ( - Date.now() > this.lastDragTime + this.nodrawDragDuration && - Date.now() > this.lastRefresh + this.refreshRate + now > this.lastDragTime + this.nodrawDragDuration && + now > this.lastRefresh + this.refreshRate ) { - this.lastRefresh = Date.now(); + this.lastRefresh = now; this.renderTerritory(); this.context.putImageData(this.imageData, 0, 0); }