Skip to content
This repository was archived by the owner on Dec 19, 2024. It is now read-only.

Comments

Ensure _applyIcon is not called multiple times. Fixes #120#121

Open
kevinpschaaf wants to merge 1 commit intomasterfrom
120-kschaaf-fix-perf
Open

Ensure _applyIcon is not called multiple times. Fixes #120#121
kevinpschaaf wants to merge 1 commit intomasterfrom
120-kschaaf-fix-perf

Conversation

@kevinpschaaf
Copy link
Contributor

@kevinpschaaf kevinpschaaf commented Feb 1, 2018

Fixes #120

Adds a dirty check on icon and theme in _updateIcon so that it avoids expensive work (cloning the SVG) if we've done it once for this icon/theme combination.

No test changes since it only affects performance, not correctness.

this.listen(window, 'iron-iconset-added', '_updateIcon');
// Since _updateIcon can be called multiple times, make sure we
// avoid cloning the SVG if the icon & theme haven't changed
if (this._iconName !== this._lastIconName ||

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we introduce two constants right above for these inequality comparisons to increase readability? I’d suggest iconNameChanged and themeChanged

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants