visitor->trace(m_currentNode);
}
-private:
- NodeType* nodeBeforeCachedNode(const Collection&, unsigned index);
- NodeType* nodeAfterCachedNode(const Collection&, unsigned index);
-
+protected:
ALWAYS_INLINE NodeType* cachedNode() const { return m_currentNode; }
ALWAYS_INLINE unsigned cachedNodeIndex() const { ASSERT(cachedNode()); return m_cachedNodeIndex; }
ALWAYS_INLINE void setCachedNode(NodeType* node, unsigned index)
m_isLengthCacheValid = true;
}
+private:
+ NodeType* nodeBeforeCachedNode(const Collection&, unsigned index);
+ NodeType* nodeAfterCachedNode(const Collection&, unsigned index);
+
RawPtrWillBeMember<NodeType> m_currentNode;
unsigned m_cachedNodeCount;
unsigned m_cachedNodeIndex : 31;
// No valid cache yet, let's find the first matching element.
ASSERT(!isCachedNodeCountValid());
- NodeType* firstNode = collection.traverseToFirstElement();
+ NodeType* firstNode = collection.traverseToFirst();
if (!firstNode) {
// The collection is empty.
setCachedNodeCount(0);
// Determine if we should traverse from the beginning of the collection instead of the cached node.
bool firstIsCloser = index < currentIndex - index;
if (firstIsCloser || !collection.canTraverseBackward()) {
- NodeType* firstNode = collection.traverseToFirstElement();
+ NodeType* firstNode = collection.traverseToFirst();
ASSERT(firstNode);
setCachedNode(firstNode, 0);
return index ? nodeAfterCachedNode(collection, index) : firstNode;
// Determine if we should traverse from the end of the collection instead of the cached node.
bool lastIsCloser = isCachedNodeCountValid() && cachedNodeCount() - index < index - currentIndex;
if (lastIsCloser && collection.canTraverseBackward()) {
- NodeType* lastItem = collection.traverseToLastElement();
+ NodeType* lastItem = collection.traverseToLast();
ASSERT(lastItem);
setCachedNode(lastItem, cachedNodeCount() - 1);
if (index < cachedNodeCount() - 1)