Closed Bug 895778 Opened 11 years ago Closed 11 years ago

Optimize code path of CustomizableUIInternal.registerToolbar

Categories

(Firefox :: Toolbars and Customization, defect)

defect
Not set
normal

Tracking

()

RESOLVED FIXED
Firefox 28

People

(Reporter: jaws, Assigned: jaws)

References

Details

(Whiteboard: [Australis:M8])

Attachments

(1 file, 1 obsolete file)

Attached patch registerToolbar.patch (obsolete) (deleted) — Splinter Review
My homegrown profiler has shown that registerToolbar is the worst offender of CustomizableUIInternal when opening windows in tpaint.

The attached patch folds some calls to hasAttribute/getAttribute. It also removes isBuildAreaRegistered because the registerBuildArea already protects against a pre-registered build area.

While here I noticed that the aContainer argument of setLocationAttributes is unused so I killed it with fire.

Baseline try push:
https://tbpl.mozilla.org/?tree=Try&rev=9f4f2e41cc7c

With patch:
https://tbpl.mozilla.org/?tree=Try&rev=e527965b8891
Attachment #778329 - Flags: review?(mnoorenberghe+bmo)
Comment on attachment 778329 [details] [diff] [review]
registerToolbar.patch

Review of attachment 778329 [details] [diff] [review]:
-----------------------------------------------------------------

Driveby feedback - sorry. Looks good, but I have some suggestions/comments...

::: browser/components/customizableui/src/CustomizableUI.jsm
@@ -474,5 @@
>    registerMenuPanel: function(aPanel) {
> -    if (this.isBuildAreaRegistered(CustomizableUI.AREA_PANEL, aPanel)) {
> -      return;
> -    }
> -

Actually, this function gets called whenever the menupanel is opened (ensureRegistered in panelUI is called). Executing all the rest of this function every time seems senseless. If this case of running it twice is not an issue for toolbars, excellent, but then let's move the code here, or to panelUI, so we don't do this more than once...

@@ +1737,3 @@
>        let parent = aElement.parentNode;
> +      let parentFlex = parseInt(parent.getAttribute("flex") || 0, 10);
> +      elementFlex = parseInt(elementFlex, 10);

This will be NaN if add-ons put bogus values in the attribute. Should we use || 0 to care about that?

Also, if we're going for speed, you can just coerce the string value rather than using parseInt (which is slower because it can also deal with "123junk" rather than just "123").
Attachment #778329 - Flags: feedback+
Attached patch 895778.patch (deleted) — Splinter Review
Gijs: Thank you for the feedback!

I've updated the patch to use type coercion instead of parseInt and sent it tryserver (also including mochitest-bc), https://tbpl.mozilla.org/?tree=Try&rev=e68904b42bcd
Attachment #778329 - Attachment is obsolete: true
Attachment #778329 - Flags: review?(mnoorenberghe+bmo)
Attachment #778678 - Flags: review?(mnoorenberghe+bmo)
I failed on getting mochitest-bc tests to run because I screw up the syntax for the try push. Repushed to try server to just run the mochitest-browser-chrome test suite, https://tbpl.mozilla.org/?tree=Try&rev=1bcde58db628
Attachment #778678 - Flags: review?(gijskruitbosch+bugs)
Comment on attachment 778678 [details] [diff] [review]
895778.patch

Review of attachment 778678 [details] [diff] [review]:
-----------------------------------------------------------------

LGTM.
Attachment #778678 - Flags: review?(gijskruitbosch+bugs) → review+
Comment on attachment 778678 [details] [diff] [review]
895778.patch

Gijs knows this code better than me.
Attachment #778678 - Flags: review?(mnoorenberghe+bmo)
Comment on attachment 778678 [details] [diff] [review]
895778.patch

Review of attachment 778678 [details] [diff] [review]:
-----------------------------------------------------------------

Ditto!
Attachment #778678 - Flags: review+
https://hg.mozilla.org/mozilla-central/rev/69e73126983c
Status: ASSIGNED → RESOLVED
Closed: 11 years ago
Resolution: --- → FIXED
Whiteboard: [Australis:M8][fixed-in-ux] → [Australis:M8]
Target Milestone: --- → Firefox 28
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: