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

Unified Diff: Source/core/rendering/OrderIterator.h

Issue 18978010: Setting up OrderIterator shouldn't require an extra Vector (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Updated after cbiesinger's review Created 7 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 | « no previous file | Source/core/rendering/OrderIterator.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/rendering/OrderIterator.h
diff --git a/Source/core/rendering/OrderIterator.h b/Source/core/rendering/OrderIterator.h
index 2b6108c3395e915f71e7b73afa6db3178ce9872d..8639bdcb1001f7a24c31fcdf2470ab73822bf86d 100644
--- a/Source/core/rendering/OrderIterator.h
+++ b/Source/core/rendering/OrderIterator.h
@@ -41,9 +41,10 @@ class RenderBox;
class OrderIterator {
WTF_MAKE_NONCOPYABLE(OrderIterator);
public:
+ friend class OrderIteratorPopulator;
+
OrderIterator(const RenderBox*);
- void setOrderValues(Vector<int>&);
RenderBox* currentChild() const { return m_currentChild; }
RenderBox* first();
RenderBox* next();
@@ -52,10 +53,35 @@ public:
private:
const RenderBox* m_containerBox;
RenderBox* m_currentChild;
- Vector<int> m_orderValues;
+ // The inline capacity for a single item is used to cover the most
+ // common case by far: if we only have the default 'order' value 0.
+ typedef Vector<int, 1> OrderValues;
+ OrderValues m_orderValues;
Vector<int>::const_iterator m_orderValuesIterator;
};
+class OrderIteratorPopulator {
+public:
+ OrderIteratorPopulator(OrderIterator& iterator)
+ : m_iterator(iterator)
+ , m_anyChildHasDefaultOrderValue(false)
+ {
+ // Note that we don't release the memory here, we only invalidate the size.
+ // This avoids unneeded reallocation if the size ends up not changing.
+ m_iterator.m_orderValues.shrink(0);
+ }
+
+ ~OrderIteratorPopulator();
+
+ void collectChild(const RenderBox*);
+
+private:
+ void removeDuplicatedOrderValues();
+
+ OrderIterator& m_iterator;
+ bool m_anyChildHasDefaultOrderValue;
+};
+
} // namespace WebCore
#endif // OrderIterator_h
« no previous file with comments | « no previous file | Source/core/rendering/OrderIterator.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698