Closed Bug 209780 Opened 21 years ago Closed 21 years ago

document.getElementById converts ucs2 to utf8 too often

Categories

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

defect
Not set
normal

Tracking

()

RESOLVED FIXED

People

(Reporter: axel, Assigned: alecf)

References

Details

(Keywords: perf)

Attachments

(1 file)

This is another side effect of alecf's utf8 atoms. We compare the id atom
of a nsIXMLContent to the ucs2 encoded id value. We should convert that to
utf8 once and compare that. See the code in MatchElementId,
http://lxr.mozilla.org/seamonkey/source/content/xml/document/src/nsXMLDocument.cpp#1022
ooh, this is an easy fix... just make MatchElementId take a UTF8 string instead,
and then fix the caller to create the UTF8 string early on... the real problem
is that GetElementById does a recursive descent on the dom tree. 

I'll even do the work, since I caused the regression.
Assignee: dom_bugs → alecf
and here's the speedup
note that I kept both the UTF16 and the UTF8 strings around - the reason is
that for HTML elements, we do a direct string compare out of GetAttr() - so we
need the UTF16 version... but when checking against the atom value, we can use
the UTF8 version.

looking for reviews.
Comment on attachment 125908 [details] [diff] [review]
speedup MatchElementId

And here's the fix, pretty short - requesting reviews from dbaron/jst but would
also accept an r= from axel..
Attachment #125908 - Flags: superreview?(jst)
Attachment #125908 - Flags: review?(dbaron)
Comment on attachment 125908 [details] [diff] [review]
speedup MatchElementId

sr=jst
Attachment #125908 - Flags: superreview?(jst) → superreview+
Blocks: 203448
fixed!
Status: NEW → RESOLVED
Closed: 21 years ago
Resolution: --- → FIXED
Component: DOM: Core → DOM: Core & HTML
QA Contact: desale → general
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: