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

Unified Diff: Source/core/css/SiblingTraversalStrategies.h

Issue 15871005: Avoid N^2 walk placing renderers when building the render tree (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Again, updating to ToT. Created 7 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/css/SiblingTraversalStrategies.h
diff --git a/Source/core/css/SiblingTraversalStrategies.h b/Source/core/css/SiblingTraversalStrategies.h
index 660a6c5edd3201bb12fbc303dbca15da6c5113de..f325ce018f7b0b43b23fe2f245a624e4284193fa 100644
--- a/Source/core/css/SiblingTraversalStrategies.h
+++ b/Source/core/css/SiblingTraversalStrategies.h
@@ -79,14 +79,8 @@ inline bool DOMSiblingTraversalStrategy::isLastOfType(Element* element, const Qu
inline int DOMSiblingTraversalStrategy::countElementsBefore(Element* element) const
{
int count = 0;
- for (const Element* sibling = element->previousElementSibling(); sibling; sibling = sibling->previousElementSibling()) {
- unsigned index = sibling->childIndex();
- if (index) {
- count += index;
- break;
- }
- count++;
- }
+ for (const Element* sibling = element->previousElementSibling(); sibling; sibling = sibling->previousElementSibling())
+ ++count;
return count;
}
@@ -105,8 +99,14 @@ inline int DOMSiblingTraversalStrategy::countElementsOfTypeBefore(Element* eleme
inline int DOMSiblingTraversalStrategy::countElementsAfter(Element* element) const
{
int count = 0;
- for (const Element* sibling = element->nextElementSibling(); sibling; sibling = sibling->nextElementSibling())
+ for (const Element* sibling = element->nextElementSibling(); sibling; sibling = sibling->nextElementSibling()) {
+ unsigned index = sibling->childIndex();
ojan 2013/06/03 23:03:29 I think here and in countElementsBefore we need co
+ if (index) {
+ count += index;
+ break;
+ }
++count;
+ }
return count;
}

Powered by Google App Engine
This is Rietveld 408576698