Bug 76600

Summary: DynamicNodeList: Simplify internal Caches object.
Product: WebKit Reporter: Andreas Kling <kling>
Component: DOMAssignee: Andreas Kling <kling>
Status: RESOLVED FIXED    
Severity: Normal CC: rniwa, webkit.review.bot
Priority: P2    
Version: 528+ (Nightly build)   
Hardware: Unspecified   
OS: Unspecified   
Attachments:
Description Flags
Patch rniwa: review+

Description Andreas Kling 2012-01-18 20:25:49 PST
We should move m_caches from DynamicSubtreeNodeList and ChildNodeList up into the common base class, DynamicNodeList.
And since there's no longer a need for the Caches object to be ref-counted, we could do away with the RefCounted inheritance.
Comment 1 Andreas Kling 2012-01-18 20:35:11 PST
Created attachment 123060 [details]
Patch
Comment 2 WebKit Review Bot 2012-01-18 20:39:10 PST
Attachment 123060 [details] did not pass style-queue:

Failed to run "['Tools/Scripts/check-webkit-style', '--diff-files', u'Source/WebCore/ChangeLog', u'Source/WebCor..." exit_code: 1

Source/WebCore/dom/DynamicNodeList.cpp:99:  An else if statement should be written as an if statement when the prior "if" concludes with a return, break, continue or goto statement.  [readability/control_flow] [4]
Total errors found: 1 in 5 files


If any of these errors are false positives, please file a bug against check-webkit-style.
Comment 3 Ryosuke Niwa 2012-01-18 20:47:56 PST
Comment on attachment 123060 [details]
Patch

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

Excellent! Saves 4 bytes per node list!

>> Source/WebCore/dom/DynamicNodeList.cpp:99
>> +        if (offset == m_caches.lastItemOffset)
> 
> An else if statement should be written as an if statement when the prior "if" concludes with a return, break, continue or goto statement.  [readability/control_flow] [4]

Please address this style warning before landing the patch.

> Source/WebCore/dom/DynamicNodeList.h:69
> +        unsigned cachedLength;
> +        unsigned lastItemOffset;
> +        bool isLengthCacheValid : 1;
> +        bool isItemCacheValid : 1;

You should steal 2 bits from lastItemOffset. Be sure to add a compile assert & change bools to unsigned to work-around MSVC behavior.
Comment 4 Andreas Kling 2012-01-19 05:54:00 PST
Committed r105408: <http://trac.webkit.org/changeset/105408>