Bug 76600 - DynamicNodeList: Simplify internal Caches object.
Summary: DynamicNodeList: Simplify internal Caches object.
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: DOM (show other bugs)
Version: 528+ (Nightly build)
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Andreas Kling
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-01-18 20:25 PST by Andreas Kling
Modified: 2012-01-19 05:54 PST (History)
2 users (show)

See Also:


Attachments
Patch (10.70 KB, patch)
2012-01-18 20:35 PST, Andreas Kling
rniwa: review+
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
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>