[webkit-reviews] review requested: [Bug 12988] First element (in document order) is not returned when other duplicate ID-ed elements were created first : [Attachment 16193] alternate patch: a fixed version of Rob's patch

bugzilla-daemon at webkit.org bugzilla-daemon at webkit.org
Tue Sep 4 05:27:01 PDT 2007


Maciej Stachowiak <mjs at apple.com> has asked  for review:
Bug 12988: First element (in document order) is not returned when other
duplicate ID-ed elements were created first
http://bugs.webkit.org/show_bug.cgi?id=12988

Attachment 16193: alternate patch: a fixed version of Rob's patch
http://bugs.webkit.org/attachment.cgi?id=16193&action=edit

------- Additional Comments from Maciej Stachowiak <mjs at apple.com>
This patch would use about 8k more memory on a page with 1000 ids, none of
which were duplicates. (On the other hand, the current approach would use 2k
more if every other one was a duplicate). This isn't very much memory in the
grand scheme of things I guess, but the duplicate case is supposed to be rare
so I think it's ok to use a few extra hash lookups to save a bit of memory.

Thinking about it, I don't see how Rob's patch would leak a duplicate Id in the
situation described. The two adds would leave the duplicate ID count at 1, with
a cleared cache, the getElementById call would leave it alone but restore the
cache, and the two removes would reduce it by 1. But I think a sequence of
add/add/remove/remove would underflow the duplicate count, since it would be
increased once but reduced twice.

Here's what I think is a fixed version of Rob's patch, in case it is of
interest.



More information about the webkit-reviews mailing list