RESOLVED FIXED 195743
Optimize Region for single rectangle case
https://bugs.webkit.org/show_bug.cgi?id=195743
Summary Optimize Region for single rectangle case
Antti Koivisto
Reported 2019-03-14 05:33:04 PDT
Instrumentation shows vast majority of Region objects consist of a single rectangle. However it always allocates the large Shape data structure. This makes it unsuitable to use as a member in any popular objects.
Attachments
patch (26.77 KB, patch)
2019-03-14 06:00 PDT, Antti Koivisto
no flags
patch (26.79 KB, patch)
2019-03-14 08:14 PDT, Antti Koivisto
simon.fraser: review+
patch (29.96 KB, patch)
2019-03-15 02:27 PDT, Antti Koivisto
no flags
patch (28.41 KB, patch)
2019-03-15 03:21 PDT, Antti Koivisto
no flags
patch (29.02 KB, patch)
2019-03-15 03:53 PDT, Antti Koivisto
no flags
patch (26.35 KB, patch)
2019-03-15 06:17 PDT, Antti Koivisto
no flags
patch (26.47 KB, patch)
2019-03-15 06:22 PDT, Antti Koivisto
no flags
patch (27.07 KB, patch)
2019-03-15 07:00 PDT, Antti Koivisto
no flags
patch (27.76 KB, patch)
2019-03-15 07:23 PDT, Antti Koivisto
no flags
patch (28.12 KB, patch)
2019-03-15 07:45 PDT, Antti Koivisto
no flags
Antti Koivisto
Comment 1 2019-03-14 06:00:19 PDT
Antti Koivisto
Comment 2 2019-03-14 08:14:27 PDT
Simon Fraser (smfr)
Comment 3 2019-03-14 08:57:05 PDT
Comment on attachment 364659 [details] patch View in context: https://bugs.webkit.org/attachment.cgi?id=364659&action=review > Source/WebCore/platform/graphics/Region.cpp:60 > +Region::~Region() = default > Source/WebCore/platform/graphics/Region.cpp:85 > + if (!m_bounds.isEmpty()) > + rects.append(m_bounds); > + return rects; Since this is the common case, maybe reserveInitialCapacity(1) and uncheckedAppend here, avoiding wasted vector capacity. > Source/WebCore/platform/graphics/Region.h:189 > + return a.m_bounds == b.m_bounds && arePointingToEqualData(a.m_shape, b.m_shape); very nice > Source/WebCore/platform/graphics/Region.h:226 > + Optional<size_t> segmentIndex; > + decoder >> segmentIndex; I don't really find this use of Optional<> and decoder >> much clearer than testing for decode success directly.
Chris Dumez
Comment 4 2019-03-14 08:59:26 PDT
Comment on attachment 364659 [details] patch View in context: https://bugs.webkit.org/attachment.cgi?id=364659&action=review >> Source/WebCore/platform/graphics/Region.h:226 >> + decoder >> segmentIndex; > > I don't really find this use of Optional<> and decoder >> much clearer than testing for decode success directly. It's not really about readability though. The reason we changed the way we decode was to not require a default constructor for the classes being decoded.
Simon Fraser (smfr)
Comment 5 2019-03-14 10:52:52 PDT
(In reply to Chris Dumez from comment #4) > It's not really about readability though. The reason we changed the way we > decode was to not require a default constructor for the classes being > decoded. Makes sense.
Antti Koivisto
Comment 6 2019-03-15 02:27:22 PDT
Antti Koivisto
Comment 7 2019-03-15 03:21:36 PDT
Antti Koivisto
Comment 8 2019-03-15 03:53:44 PDT
Antti Koivisto
Comment 9 2019-03-15 06:17:28 PDT
Antti Koivisto
Comment 10 2019-03-15 06:22:16 PDT
Antti Koivisto
Comment 11 2019-03-15 07:00:54 PDT
Antti Koivisto
Comment 12 2019-03-15 07:23:36 PDT
Antti Koivisto
Comment 13 2019-03-15 07:45:37 PDT
WebKit Commit Bot
Comment 14 2019-03-15 08:43:26 PDT
Comment on attachment 364795 [details] patch Clearing flags on attachment: 364795 Committed r242995: <https://trac.webkit.org/changeset/242995>
WebKit Commit Bot
Comment 15 2019-03-15 08:43:28 PDT
All reviewed patches have been landed. Closing bug.
Radar WebKit Bug Importer
Comment 16 2019-03-15 08:44:17 PDT
Note You need to log in before you can comment on or make changes to this bug.