[webkit-changes] cvs commit: WebCore/khtml/xml dom_nodeimpl.cpp
Timothy
thatcher at opensource.apple.com
Fri Dec 2 01:13:27 PST 2005
thatcher 05/12/02 01:13:27
Modified: . ChangeLog
khtml/xml dom_nodeimpl.cpp
Log:
Reviewed by Maciej.
Cache the lastItem and lastItemOffset for fast retrieval of the
same index or indeicies greater than lastItemOffset. Also cache
the length. Like other node lists these cached values rest when the
subtree under the root node changes.
* khtml/xml/dom_nodeimpl.cpp:
(ChildNodeListImpl::length): Use cachedLength when possible.
(ChildNodeListImpl::item): Use lastItemOffset and lastItem if we can.
Revision Changes Path
1.450 +13 -0 WebCore/ChangeLog
Index: ChangeLog
===================================================================
RCS file: /cvs/root/WebCore/ChangeLog,v
retrieving revision 1.449
retrieving revision 1.450
diff -u -r1.449 -r1.450
--- ChangeLog 2 Dec 2005 09:00:25 -0000 1.449
+++ ChangeLog 2 Dec 2005 09:13:22 -0000 1.450
@@ -1,3 +1,16 @@
+2005-12-02 Timothy Hatcher <timothy at apple.com>
+
+ Reviewed by Maciej.
+
+ Cache the lastItem and lastItemOffset for fast retrieval of the
+ same index or indeicies greater than lastItemOffset. Also cache
+ the length. Like other node lists these cached values rest when the
+ subtree under the root node changes.
+
+ * khtml/xml/dom_nodeimpl.cpp:
+ (ChildNodeListImpl::length): Use cachedLength when possible.
+ (ChildNodeListImpl::item): Use lastItemOffset and lastItem if we can.
+
2005-12-01 Graham Dennis <Graham.Dennis at gmail.com>
<http://bugzilla.opendarwin.org/show_bug.cgi?id=4003>
1.220 +26 -4 WebCore/khtml/xml/dom_nodeimpl.cpp
Index: dom_nodeimpl.cpp
===================================================================
RCS file: /cvs/root/WebCore/khtml/xml/dom_nodeimpl.cpp,v
retrieving revision 1.219
retrieving revision 1.220
diff -u -r1.219 -r1.220
--- dom_nodeimpl.cpp 1 Dec 2005 23:45:21 -0000 1.219
+++ dom_nodeimpl.cpp 2 Dec 2005 09:13:26 -0000 1.220
@@ -2915,7 +2915,7 @@
if (!remainingOffset) {
lastItem = n;
lastItemOffset = offset;
- isItemCacheValid = 1;
+ isItemCacheValid = true;
return n;
}
remainingOffset--;
@@ -2962,6 +2962,7 @@
{
isLengthCacheValid = false;
isItemCacheValid = false;
+ lastItem = 0;
}
ChildNodeListImpl::ChildNodeListImpl( NodeImpl *n )
@@ -2971,11 +2972,17 @@
unsigned ChildNodeListImpl::length() const
{
+ if (isLengthCacheValid)
+ return cachedLength;
+
unsigned len = 0;
NodeImpl *n;
for(n = rootNode->firstChild(); n != 0; n = n->nextSibling())
len++;
+ cachedLength = len;
+ isLengthCacheValid = true;
+
return len;
}
@@ -2984,13 +2991,28 @@
unsigned int pos = 0;
NodeImpl *n = rootNode->firstChild();
- while( n != 0 && pos < index )
- {
+ if (isItemCacheValid) {
+ if (index == lastItemOffset) {
+ return lastItem;
+ } else if (index > lastItemOffset) {
+ n = lastItem;
+ pos = lastItemOffset;
+ }
+ }
+
+ while (n && pos < index) {
n = n->nextSibling();
pos++;
}
- return n;
+ if (n) {
+ lastItem = n;
+ lastItemOffset = pos;
+ isItemCacheValid = true;
+ return n;
+ }
+
+ return 0;
}
bool ChildNodeListImpl::nodeMatches(NodeImpl *testNode) const
More information about the webkit-changes
mailing list