[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
pull/504/head
Bjorn Stromberg 4 years ago committed by GitHub
parent 2be3eae2aa
commit 6d01c482d8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -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;

Loading…
Cancel
Save