Changeset 157916 in webkit
- Timestamp:
- Oct 23, 2013 11:53:10 PM (10 years ago)
- Location:
- trunk
- Files:
-
- 1 added
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/PerformanceTests/ChangeLog
r157009 r157916 1 2013-10-14 Sergio Villar Senin <svillar@igalia.com> 2 3 Use a Vector instead of HashSet to computed the orderValues in RenderFlexibleBox 4 https://bugs.webkit.org/show_bug.cgi?id=118620 5 6 Reviewed by Antti Koivisto. 7 8 From Blink r152960 by <ojan@chromium.org> 9 10 New performance test for layouts in flexboxes. 11 12 * Layout/flexbox-lots-of-data.html: Added. 13 1 14 2013-10-06 Ryosuke Niwa <rniwa@webkit.org> 2 15 -
trunk/Source/WebCore/ChangeLog
r157915 r157916 1 2013-10-14 Sergio Villar Senin <svillar@igalia.com> 2 3 Use a Vector instead of HashSet to computed the orderValues in RenderFlexibleBox 4 https://bugs.webkit.org/show_bug.cgi?id=118620 5 6 Reviewed by Antti Koivisto. 7 8 Turns out that order is extremelly uncommon so using a Vector is 9 much less expensive. This also special-cases the much common case 10 of only having order of value 0 by using Vectors with just one 11 preallocated member. 12 13 Also added the performance test that shows a ~1% win when using a 14 vector instead of the HashSet. 15 16 * rendering/RenderFlexibleBox.cpp: 17 (WebCore::RenderFlexibleBox::OrderIterator::setOrderValues): 18 (WebCore::RenderFlexibleBox::layoutBlock): 19 (WebCore::RenderFlexibleBox::computeMainAxisPreferredSizes): 20 * rendering/RenderFlexibleBox.h: 21 1 22 2013-10-23 ChangSeok Oh <changseok.oh@collabora.com> 2 23 -
trunk/Source/WebCore/rendering/RenderFlexibleBox.cpp
r157828 r157916 40 40 namespace WebCore { 41 41 42 // Normally, -1 and 0 are not valid in a HashSet, but these are relatively likely order: values. Instead,43 // we make the two smallest int values invalid order: values (in the css parser code we clamp them to44 // int min + 2).45 struct RenderFlexibleBox::OrderHashTraits : WTF::GenericHashTraits<int> {46 static const bool emptyValueIsZero = false;47 static int emptyValue() { return std::numeric_limits<int>::min(); }48 static void constructDeletedValue(int& slot) { slot = std::numeric_limits<int>::min() + 1; }49 static bool isDeletedValue(int value) { return value == std::numeric_limits<int>::min() + 1; }50 };51 52 42 RenderFlexibleBox::OrderIterator::OrderIterator(const RenderFlexibleBox* flexibleBox) 53 43 : m_flexibleBox(flexibleBox) … … 57 47 } 58 48 59 void RenderFlexibleBox::OrderIterator::setOrderValues(const Order HashSet& orderValues)49 void RenderFlexibleBox::OrderIterator::setOrderValues(const OrderValues& orderValues) 60 50 { 61 51 reset(); 62 copyToVector(orderValues, m_orderValues); 52 m_orderValues = orderValues; 53 if (m_orderValues.size() < 2) 54 return; 55 63 56 std::sort(m_orderValues.begin(), m_orderValues.end()); 57 auto nextElement = std::unique(m_orderValues.begin(), m_orderValues.end()); 58 m_orderValues.shrinkCapacity(nextElement - m_orderValues.begin()); 64 59 } 65 60 … … 349 344 350 345 Vector<LineContext> lineContexts; 351 Order HashSetorderValues;346 OrderIterator::OrderValues orderValues; 352 347 computeMainAxisPreferredSizes(orderValues); 353 348 m_orderIterator.setOrderValues(orderValues); … … 909 904 } 910 905 911 void RenderFlexibleBox::computeMainAxisPreferredSizes(OrderHashSet& orderValues) 912 { 906 void RenderFlexibleBox::computeMainAxisPreferredSizes(OrderIterator::OrderValues& orderValues) 907 { 908 ASSERT(orderValues.isEmpty()); 909 913 910 for (RenderBox* child = firstChildBox(); child; child = child->nextSiblingBox()) { 914 orderValues.add(child->style()->order()); 911 // Avoid growing the vector for the common-case default value of 0. This optimizes the most common case which is 912 // one or a few values with the default order 0 913 int order = child->style()->order(); 914 if (orderValues.isEmpty() || orderValues.last() != order) 915 orderValues.append(order); 915 916 916 917 if (child->isOutOfFlowPositioned()) -
trunk/Source/WebCore/rendering/RenderFlexibleBox.h
r157907 r157916 74 74 }; 75 75 76 struct OrderHashTraits;77 typedef HashSet<int, DefaultHash<int>::Hash, OrderHashTraits> OrderHashSet;78 79 76 class OrderIterator { 80 77 WTF_MAKE_NONCOPYABLE(OrderIterator); 81 78 public: 79 typedef Vector<int, 1> OrderValues; 80 82 81 OrderIterator(const RenderFlexibleBox*); 83 void setOrderValues(const Order HashSet&);82 void setOrderValues(const OrderValues&); 84 83 RenderBox* currentChild() const { return m_currentChild; } 85 84 RenderBox* first(); … … 90 89 const RenderFlexibleBox* m_flexibleBox; 91 90 RenderBox* m_currentChild; 92 Vector<int>m_orderValues;91 OrderValues m_orderValues; 93 92 Vector<int>::const_iterator m_orderValuesIterator; 94 93 }; … … 154 153 155 154 LayoutUnit computeChildMarginValue(const Length& margin); 156 void computeMainAxisPreferredSizes(Order HashSet&);155 void computeMainAxisPreferredSizes(OrderIterator::OrderValues&); 157 156 LayoutUnit adjustChildSizeForMinAndMax(RenderBox&, LayoutUnit childSize); 158 157 bool computeNextFlexLine(OrderedFlexItemList& orderedChildren, LayoutUnit& preferredMainAxisExtent, double& totalFlexGrow, double& totalWeightedFlexShrink, LayoutUnit& minMaxAppliedMainAxisExtent, bool& hasInfiniteLineLength);
Note: See TracChangeset
for help on using the changeset viewer.