Closed Bug 1977550 Opened 8 months ago Closed 8 months ago

ElementStyle#_hasUpdatedCSSVariable can be slow when there is a lot of CSS variables

Categories

(DevTools :: Inspector: Rules, defect, P3)

defect

Tracking

(firefox142 fixed)

RESOLVED FIXED
142 Branch
Tracking Status
firefox142 --- fixed

People

(Reporter: nchevobbe, Assigned: nchevobbe)

References

(Blocks 1 open bug)

Details

Attachments

(1 file)

In Bug 1903632, I found that _hasUpdatedCSSVariable is taking half a second on https://hh.ru/search/resume?area=85 (https://share.firefox.dev/3VQSGdo).
That's because we're looping through a Set that is probably quite large here https://searchfox.org/mozilla-central/rev/74518d4f6979b088e28405ba7e6238f4707639cf/devtools/client/inspector/rules/models/element-style.js#507-515

_hasUpdatedCSSVariable(declaration, variableNamesSet) {
  for (const variableName of variableNamesSet) {
    if (declaration.hasCSSVariable(variableName)) {
      return true;
    }
  }

  return false;
}

This is way faster than iterating through the Set.

Assignee: nobody → nchevobbe
Status: NEW → ASSIGNED
Severity: -- → S3
Priority: -- → P3
Pushed by nchevobbe@mozilla.com: https://github.com/mozilla-firefox/firefox/commit/f30686cab907 https://hg.mozilla.org/integration/autoland/rev/e144109f611d [devtools] Use Set#isDisjointFrom in ElementStyle#_hasUpdatedCssVariable. r=devtools-reviewers,ochameau.
Status: ASSIGNED → RESOLVED
Closed: 8 months ago
Resolution: --- → FIXED
Target Milestone: --- → 142 Branch
QA Whiteboard: [qa-triage-done-c143/b142]
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: