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

Unified Diff: Source/core/dom/Node.cpp

Issue 308963002: Minimize calls to Node::nodeType() as it is virtual (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Fix typo Created 6 years, 7 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
Index: Source/core/dom/Node.cpp
diff --git a/Source/core/dom/Node.cpp b/Source/core/dom/Node.cpp
index e9a4172aa4ef341cb4df6eb9872289db5383a129..c9a401485eea2cae98a489199e7ce4ec0180c8e3 100644
--- a/Source/core/dom/Node.cpp
+++ b/Source/core/dom/Node.cpp
@@ -494,14 +494,13 @@ void Node::normalize()
while (Node* firstChild = node->firstChild())
node = firstChild;
while (node) {
- NodeType type = node->nodeType();
- if (type == ELEMENT_NODE)
+ if (node->isElementNode())
toElement(node)->normalizeAttributes();
if (node == this)
break;
- if (type == TEXT_NODE)
+ if (node->nodeType() == TEXT_NODE)
aandrey 2014/06/02 14:50:51 node->isTextNode() ?
Inactive 2014/06/02 15:48:02 This is not equivalent, isTextNode() returns true
node = toText(node)->mergeNextSiblingNodesIfPossible();
else
node = NodeTraversal::nextPostOrder(*node);
@@ -1468,7 +1467,8 @@ static void appendTextContent(const Node* node, bool convertBRsToNewlines, bool&
case Node::DOCUMENT_FRAGMENT_NODE:
isNullString = false;
for (Node* child = node->firstChild(); child; child = child->nextSibling()) {
- if (child->nodeType() == Node::COMMENT_NODE || child->nodeType() == Node::PROCESSING_INSTRUCTION_NODE)
+ Node::NodeType childNodeType = child->nodeType();
+ if (childNodeType == Node::COMMENT_NODE || childNodeType == Node::PROCESSING_INSTRUCTION_NODE)
continue;
appendTextContent(child, convertBRsToNewlines, isNullString, content);
}

Powered by Google App Engine
This is Rietveld 408576698