Closed Bug 1422529 Opened 7 years ago Closed 7 years ago

Some trivial element methods are hidden behind virtual calls and could be devirtualized.

Categories

(Core :: DOM: Core & HTML, defect, P3)

defect

Tracking

()

RESOLVED FIXED
mozilla59
Tracking Status
firefox59 --- fixed

People

(Reporter: emilio, Assigned: emilio)

References

Details

Attachments

(1 file)

Noticed while looking at bug 1422528.
Comment on attachment 8933942 [details] Bug 1422529: Make some trivial element methods final and inline. https://reviewboard.mozilla.org/r/204876/#review210404 ::: dom/base/Element.h:786 (Diff revision 1) > AttrValuesArray* aValues, > nsCaseTreatment aCaseSensitive) const override; > virtual nsresult UnsetAttr(int32_t aNameSpaceID, nsAtom* aAttribute, > bool aNotify) override; > - virtual const nsAttrName* GetAttrNameAt(uint32_t aIndex) const override; > - virtual BorrowedAttrInfo GetAttrInfoAt(uint32_t aIndex) const override; > + > + virtual const nsAttrName* GetAttrNameAt(uint32_t aIndex) const final `override final`?
Comment on attachment 8933942 [details] Bug 1422529: Make some trivial element methods final and inline. https://reviewboard.mozilla.org/r/204876/#review210404 > `override final`? Huh, sure thing, thanks! :) Actually one of those didn't even need to be virtual... I went with `final override` because there was another use of it in the file, but we're inconsistent in the codebase...
Comment on attachment 8933942 [details] Bug 1422529: Make some trivial element methods final and inline. https://reviewboard.mozilla.org/r/204876/#review210682 ::: dom/base/Element.h:787 (Diff revision 2) > AttrValuesArray* aValues, > nsCaseTreatment aCaseSensitive) const override; > virtual nsresult UnsetAttr(int32_t aNameSpaceID, nsAtom* aAttribute, > bool aNotify) override; > - virtual const nsAttrName* GetAttrNameAt(uint32_t aIndex) const override; > - virtual BorrowedAttrInfo GetAttrInfoAt(uint32_t aIndex) const override; > + > + virtual const nsAttrName* GetAttrNameAt(uint32_t aIndex) const final override This is OK, but we could do a followup to move GetAttrNameAt to Element and devirtualize it altogether. ::: dom/base/Element.h:792 (Diff revision 2) > - virtual BorrowedAttrInfo GetAttrInfoAt(uint32_t aIndex) const override; > - virtual uint32_t GetAttrCount() const override; > + virtual const nsAttrName* GetAttrNameAt(uint32_t aIndex) const final override > + { > + return mAttrsAndChildren.GetSafeAttrNameAt(aIndex); > + } > + > + virtual BorrowedAttrInfo GetAttrInfoAt(uint32_t aIndex) const final override Again, could be moved to Element. Doing that cleanly involves changing some function signatures in the serializers and XBL, so followup. ::: dom/base/Element.h:801 (Diff revision 2) > + } > + > + return mAttrsAndChildren.AttrInfoAt(aIndex); > + } > + > + virtual uint32_t GetAttrCount() const final override Again might be worth moving to Element, but has more callers than the other two...
Attachment #8933942 - Flags: review?(bzbarsky) → review+
(In reply to Boris Zbarsky [:bz] (no decent commit message means r-) from comment #5) > ::: dom/base/Element.h:801 > (Diff revision 2) > > + } > > + > > + return mAttrsAndChildren.AttrInfoAt(aIndex); > > + } > > + > > + virtual uint32_t GetAttrCount() const final override > > Again might be worth moving to Element, but has more callers than the other > two... It may even be worth to convert the nsIContent version in IsElement() ? AsElement()->GetAttrCount() : 0 or such. Anyway, will file followups for those.
Priority: -- → P3
Blocks: 1423167
Pushed by ecoal95@gmail.com: https://hg.mozilla.org/integration/autoland/rev/22da077ec8f0 Make some trivial element methods final and inline. r=bz
Status: NEW → RESOLVED
Closed: 7 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla59
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: