Open Bug 1857327 Opened 1 year ago Updated 1 year ago

Consider giving EnumTable a static atom instead of a const char*

Categories

(Core :: DOM: Core & HTML, task)

task

Tracking

()

People

(Reporter: mstange, Unassigned)

References

(Blocks 1 open bug)

Details

(Whiteboard: [sp3])

When you have an nsAttrValue which contains an enum value, and you call attrValue.Equals(atom, eCaseMatters), we do more work than necessary, because we create an nsAutoString around the literal string (and have to call strlen) and then iterate over the characters to check for equality: https://share.firefox.dev/3rC3kZ7

Here are some examples of atom tables: https://searchfox.org/mozilla-central/rev/6602bdf9fff5020fbc8e248c963ddddf09a77b1b/dom/html/nsGenericHTMLElement.cpp#1072

It feels like those string literals could be static atoms instead, and this check would be cheaper.

Here's a profile of nsAttrValue::ParseEnumValue, for completeness: https://share.firefox.dev/3ZQ6Xr6

I estimate the value of the proposed optimization to be low but non-zero; around 0.041% of sp3 overall (which is equivalent to improving a single subtest by 0.85%).

You need to log in before you can comment on or make changes to this bug.