Bug 116167 - DocumentOrderedMap doesn't need to have two HashMaps
Summary: DocumentOrderedMap doesn't need to have two HashMaps
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: DOM (show other bugs)
Version: 528+ (Nightly build)
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Ryosuke Niwa
URL:
Keywords: InRadar
Depends on:
Blocks: 119780
  Show dependency treegraph
 
Reported: 2013-05-15 10:51 PDT by Ryosuke Niwa
Modified: 2013-08-13 19:16 PDT (History)
11 users (show)

See Also:


Attachments
Cleanup + accidental bug fix (27.30 KB, patch)
2013-05-15 19:50 PDT, Ryosuke Niwa
ggaren: review+
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Ryosuke Niwa 2013-05-15 10:51:30 PDT
DocumentOrderedMap has m_map and m_duplicateCounts but it doesn’t have to.
Comment 1 Ryosuke Niwa 2013-05-15 19:50:33 PDT
Created attachment 201913 [details]
Cleanup + accidental bug fix
Comment 2 Ryosuke Niwa 2013-05-15 19:51:18 PDT
<rdar://problem/13895825>
Comment 3 Darin Adler 2013-05-15 21:47:32 PDT
I might get a chance to review this later. Ryosuke, bug 80224 is also about a problem in this class.
Comment 4 Geoffrey Garen 2013-05-15 22:07:26 PDT
Comment on attachment 201913 [details]
Cleanup + accidental bug fix

View in context: https://bugs.webkit.org/attachment.cgi?id=201913&action=review

I started reviewing this and then I learned that the season finale of New Girl was available on iTunes.

> Source/WebCore/dom/DocumentOrderedMap.cpp:119
> +        entry.orderedList.clear(); // FIXME: Remove the element instead but it can't be too slow.

I'm not sure I agree with this FIXME. Removal in the duplicate id case, followed by a getElementById for that id, is not obviously worth optimizing.
Comment 5 Ryosuke Niwa 2013-05-15 22:15:13 PDT
(In reply to comment #4)
> I'm not sure I agree with this FIXME. Removal in the duplicate id case, followed by a getElementById for that id, is not obviously worth optimizing.

I think it's possible for authors to insert an element with some id, and then remove the other element of the same id next.  I agree it's probably not worth optimizing the case where there will be more than two elements with the same id, and one of them is removed.
Comment 6 Geoffrey Garen 2013-05-15 23:43:55 PDT
> I think it's possible for authors to insert an element with some id, and then remove the other element of the same id next.  I agree it's probably not worth optimizing the case where there will be more than two elements with the same id, and one of them is removed.

Sounds reasonable. Maybe the FIXME should say "FIXME: For short lists, remove the element from the list instead of clearing the list."
Comment 7 Geoffrey Garen 2013-05-15 23:50:04 PDT
Comment on attachment 201913 [details]
Cleanup + accidental bug fix

View in context: https://bugs.webkit.org/attachment.cgi?id=201913&action=review

r=me

> Source/WebCore/dom/SelectorQuery.cpp:101
> +const CSSSelector* SelectorDataList::canUseIdLookup(Node* rootNode) const

Since the return value changed, should we rename this? Something like "selectorForIdLookup"?

> Source/WebCore/dom/SelectorQuery.cpp:131
> +        const AtomicString idToMatch = idSelector->value();

Should be const AtomicString&.
Comment 8 Ryosuke Niwa 2013-05-16 00:07:49 PDT
Comment on attachment 201913 [details]
Cleanup + accidental bug fix

View in context: https://bugs.webkit.org/attachment.cgi?id=201913&action=review

Thanks for the review!

>> Source/WebCore/dom/DocumentOrderedMap.cpp:119
>> +        entry.orderedList.clear(); // FIXME: Remove the element instead but it can't be too slow.
> 
> I'm not sure I agree with this FIXME. Removal in the duplicate id case, followed by a getElementById for that id, is not obviously worth optimizing.

Will rephrase the FIXME.

>> Source/WebCore/dom/SelectorQuery.cpp:101
>> +const CSSSelector* SelectorDataList::canUseIdLookup(Node* rootNode) const
> 
> Since the return value changed, should we rename this? Something like "selectorForIdLookup"?

Oh, I must have made the exact rename on another checkout :/ Will do that again before I land.

>> Source/WebCore/dom/SelectorQuery.cpp:131
>> +        const AtomicString idToMatch = idSelector->value();
> 
> Should be const AtomicString&.

Oops, will fix.
Comment 9 Ryosuke Niwa 2013-05-16 11:05:30 PDT
Committed r150187: <http://trac.webkit.org/changeset/150187>