Closed Bug 351731 Opened 18 years ago Closed 18 years ago

nsParserService::HTMLCaseSensitiveAtomTagToId is slow

Categories

(Core :: DOM: HTML Parser, defect)

x86
Linux
defect
Not set
normal

Tracking

()

RESOLVED FIXED

People

(Reporter: bzbarsky, Assigned: sicking)

References

(Blocks 1 open bug)

Details

(Keywords: perf)

Attachments

(2 files)

Ran into this while profiling XHTML node creation. Why are we bothering to stringify the atom, hash the string, etc? Imho we should just have a hashtable mapping atoms to IDs here or something.
Keywords: perf
I'm working on this
Assignee: mrbkap → bugmail
Attached patch Patch to fix (deleted) — Splinter Review
This patch adds a hash directly from atom -> id. I also inlined some of the functions for additional speed goodness. This forced me to move some of the statics into the class which wasn't too pretty, but I think it's ok.
Attachment #241219 - Flags: superreview?(bzbarsky)
Attachment #241219 - Flags: review?(bzbarsky)
Comment on attachment 241219 [details] [diff] [review] Patch to fix >Index: parser/htmlparser/public/nsHTMLTags.h >+ friend void TestTagTable(); Just make that a static member function, perhaps? Otherwise you probably need to declare it separately before the |friend| thing; some of our compilers don't deal with effectively declaring stuff via the |friend| keyword. >Index: parser/htmlparser/src/nsHTMLTags.cpp >-static const PRUnichar* const kTagUnicodeTable[] = { >+const PRUnichar* const nsHTMLTags::sTagUnicodeTable[] = { This doesn't make me all that happy, but given the inlining I don't see a better way. :( >+HTMLTagsHashCodeAtom(const void *key) >+{ >+ return NS_PTR_TO_INT32(key); Toss in a ">> 2" there because otherwise all keys will end with 00? With that, looks good.
Attachment #241219 - Flags: superreview?(bzbarsky)
Attachment #241219 - Flags: superreview+
Attachment #241219 - Flags: review?(bzbarsky)
Attachment #241219 - Flags: review+
Checked in.
Status: NEW → RESOLVED
Closed: 18 years ago
Resolution: --- → FIXED
Attached patch Add testing for new code (deleted) — Splinter Review
Attachment #241759 - Flags: superreview?(jst)
Attachment #241759 - Flags: review?(jst)
Comment on attachment 241759 [details] [diff] [review] Add testing for new code r+sr=jst
Attachment #241759 - Flags: superreview?(jst)
Attachment #241759 - Flags: superreview+
Attachment #241759 - Flags: review?(jst)
Attachment #241759 - Flags: review+
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: