[Perf] Avoid iterating over keys to generate assert message (#486)

* Avoid iterating over keys to generate assert message

* Move assertion call behind guard

* Shorten line by using string template
This commit is contained in:
Bjorn Stromberg 2020-07-27 18:15:59 +09:00 committed by GitHub
parent 2be3eae2aa
commit 6d01c482d8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 3 additions and 1 deletions

View File

@ -158,7 +158,9 @@ export class AtlasSprite extends BaseSprite {
const scale = parameters.desiredAtlasScale;
const link = this.linksByResolution[scale];
assert(link, "Link not known: " + scale + " (having " + Object.keys(this.linksByResolution) + ")");
if (!link) {
assert(false, `Link not known: ${scale} (having ${Object.keys(this.linksByResolution)})`);
}
const scaleW = w / link.w;
const scaleH = h / link.h;