Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(652)

Unified Diff: Source/core/dom/ContainerNode.h

Issue 171953002: Get rid of inefficient uses of childNodeCount() (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Use lastChild() Created 6 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | Source/core/dom/Range.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/dom/ContainerNode.h
diff --git a/Source/core/dom/ContainerNode.h b/Source/core/dom/ContainerNode.h
index 967568d5d155b1baa67e7bac1480516fed12bd7b..62a3e3230b2b586de5a51f6d301914886bcef541 100644
--- a/Source/core/dom/ContainerNode.h
+++ b/Source/core/dom/ContainerNode.h
@@ -86,6 +86,7 @@ public:
bool hasOneChild() const { return m_firstChild && !m_firstChild->nextSibling(); }
bool hasOneTextChild() const { return hasOneChild() && m_firstChild->isTextNode(); }
+ bool hasChildCount(unsigned) const;
PassRefPtr<HTMLCollection> children();
@@ -176,6 +177,16 @@ bool childAttachedAllowedWhenAttachingChildren(ContainerNode*);
DEFINE_NODE_TYPE_CASTS(ContainerNode, isContainerNode());
+inline bool ContainerNode::hasChildCount(unsigned count) const
+{
+ Node* child = m_firstChild;
+ while (count && child) {
+ child = child->nextSibling();
+ --count;
+ }
+ return !count && !child;
+}
+
inline ContainerNode::ContainerNode(TreeScope* treeScope, ConstructionType type)
: Node(treeScope, type)
, m_firstChild(0)
« no previous file with comments | « no previous file | Source/core/dom/Range.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698