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

Unified Diff: Source/platform/geometry/Region.h

Issue 183663030: Reduce number of vector buffer reallocs in Regions::unite . (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Use new Vector::shrinkToReasonableCapacity() API. 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
« no previous file with comments | « no previous file | Source/platform/geometry/Region.cpp » ('j') | Source/platform/geometry/Region.cpp » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/platform/geometry/Region.h
diff --git a/Source/platform/geometry/Region.h b/Source/platform/geometry/Region.h
index efe743903a3524846af7af16dc2166cd00b88089..f7306a8119961ad90b2c1b606972a6cea592af8e 100644
--- a/Source/platform/geometry/Region.h
+++ b/Source/platform/geometry/Region.h
@@ -78,6 +78,7 @@ private:
public:
Shape();
Shape(const IntRect&);
+ Shape(size_t segmentsCapacity, size_t spansCapacity);
IntRect bounds() const;
bool isEmpty() const { return m_spans.isEmpty(); }
@@ -86,10 +87,12 @@ private:
typedef const Span* SpanIterator;
SpanIterator spansBegin() const;
SpanIterator spansEnd() const;
+ size_t spansSize() const { return m_spans.size(); }
typedef const int* SegmentIterator;
SegmentIterator segmentsBegin(SpanIterator) const;
SegmentIterator segmentsEnd(SpanIterator) const;
+ size_t segmentsSize() const { return m_segments.size(); }
static Shape unionShapes(const Shape& shape1, const Shape& shape2);
static Shape intersectShapes(const Shape& shape1, const Shape& shape2);
@@ -103,6 +106,7 @@ private:
template<typename CompareOperation>
static bool compareShapes(const Shape& shape1, const Shape& shape2);
+ void trimCapacities();
#ifndef NDEBUG
void dump() const;
@@ -123,8 +127,12 @@ private:
bool canCoalesce(SegmentIterator begin, SegmentIterator end);
- Vector<int, 32> m_segments;
- Vector<Span, 16> m_spans;
+ static const size_t segmentsDefaultCapacity = 32;
+ static const size_t segmentsMask = segmentsDefaultCapacity - 1;
+ Vector<int, segmentsDefaultCapacity> m_segments;
+ static const size_t spansDefaultCapacity = 16;
+ static const size_t spansMask = spansDefaultCapacity - 1;
+ Vector<Span, spansDefaultCapacity> m_spans;
friend bool operator==(const Shape&, const Shape&);
};
« no previous file with comments | « no previous file | Source/platform/geometry/Region.cpp » ('j') | Source/platform/geometry/Region.cpp » ('J')

Powered by Google App Engine
This is Rietveld 408576698