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

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

Issue 383163003: Add intentional optimization comment in Node::setTextContent (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Take review comment into consideration Created 6 years, 5 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 | « LayoutTests/fast/dom/Node/textContent-expected.txt ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/dom/Node.cpp
diff --git a/Source/core/dom/Node.cpp b/Source/core/dom/Node.cpp
index 8af4165eb24a4b736848148c34141be39e915632..d363f32a42d7cec22e08e99af6db878199dda050 100644
--- a/Source/core/dom/Node.cpp
+++ b/Source/core/dom/Node.cpp
@@ -1515,9 +1515,13 @@ void Node::setTextContent(const String& text)
case DOCUMENT_FRAGMENT_NODE: {
// FIXME: Merge this logic into replaceChildrenWithText.
RefPtrWillBeRawPtr<ContainerNode> container = toContainerNode(this);
+
+ // Note: This is an intentional optimization.
+ // See crbug.com/352836 also.
// No need to do anything if the text is identical.
if (container->hasOneTextChild() && toText(container->firstChild())->data() == text)
return;
+
ChildListMutationScope mutation(*this);
container->removeChildren();
// Note: This API will not insert empty text nodes:
« no previous file with comments | « LayoutTests/fast/dom/Node/textContent-expected.txt ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698