RESOLVED FIXED 211656
Streamline MarkupAccumulator to improve efficiency a bit
https://bugs.webkit.org/show_bug.cgi?id=211656
Summary Streamline MarkupAccumulator to improve efficiency a bit
Darin Adler
Reported 2020-05-08 19:27:26 PDT
Streamline MarkupAccumulator to improve efficiency a bit
Attachments
Patch (40.44 KB, patch)
2020-05-08 19:49 PDT, Darin Adler
no flags
Patch (40.53 KB, patch)
2020-05-09 06:35 PDT, Darin Adler
no flags
Patch (40.52 KB, patch)
2020-05-09 07:30 PDT, Darin Adler
andersca: review+
Darin Adler
Comment 1 2020-05-08 19:49:07 PDT Comment hidden (obsolete)
Darin Adler
Comment 2 2020-05-08 23:47:28 PDT Comment hidden (obsolete)
Darin Adler
Comment 3 2020-05-09 06:35:40 PDT Comment hidden (obsolete)
Darin Adler
Comment 4 2020-05-09 07:30:25 PDT
Anders Carlsson
Comment 5 2020-05-09 08:55:14 PDT
Comment on attachment 398926 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=398926&action=review > Source/WebCore/editing/MarkupAccumulator.h:75 > + template<typename ...StringTypes> void append(StringTypes... strings) { m_markup.append(strings...); } Any reason why StringTypes isn't a forwarding reference, and why you're not using std::forward in the call?
Darin Adler
Comment 6 2020-05-09 08:55:54 PDT
Comment on attachment 398926 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=398926&action=review >> Source/WebCore/editing/MarkupAccumulator.h:75 >> + template<typename ...StringTypes> void append(StringTypes... strings) { m_markup.append(strings...); } > > Any reason why StringTypes isn't a forwarding reference, and why you're not using std::forward in the call? No reason. I will do what you suggest.
Darin Adler
Comment 7 2020-05-09 08:56:28 PDT
Also, I will need to fix the crash seen on mac-debug!
Darin Adler
Comment 8 2020-05-09 08:57:55 PDT
Ah, got the null check wrong.
Darin Adler
Comment 9 2020-05-09 09:04:05 PDT
Radar WebKit Bug Importer
Comment 10 2020-05-09 09:05:17 PDT
Sam Weinig
Comment 11 2020-05-09 15:48:12 PDT
Comment on attachment 398926 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=398926&action=review > Source/WebCore/editing/markup.cpp:407 > +// Stopgap until C++20 adds std::ranges::reverse_view. > +template<typename Collection> struct ReverseView { > + Collection& collection; > + decltype(collection.rbegin()) begin() const { return collection.rbegin(); } > + decltype(collection.rend()) end() const { return collection.rend(); } > + decltype(collection.size()) size() const { return collection.size(); } > + ReverseView(Collection& collection) > + : collection(collection) > + { > + } > +}; We really should just import a copy of our own as we did with Optional and Variant. That said, we actually have the equivalent (I think) functionality already by way of makeReversedRange() in <wtf/IteratorRange.h>.
Darin Adler
Comment 12 2020-05-09 16:22:05 PDT
(In reply to Sam Weinig from comment #11) > We really should just import a copy of our own as we did with Optional and > Variant. OK. I was just working on replacing WTF::Optional with std::optional. > That said, we actually have the equivalent (I think) functionality already > by way of makeReversedRange() in <wtf/IteratorRange.h>. I’ll try using that.
Sam Weinig
Comment 13 2020-05-09 16:31:20 PDT
(In reply to Darin Adler from comment #12) > (In reply to Sam Weinig from comment #11) > > We really should just import a copy of our own as we did with Optional and > > Variant. > > OK. > > I was just working on replacing WTF::Optional with std::optional. Sure. That's the right thing to do now. All I meant that I we brought those in before we had a copy in the standard library we could use.
Darin Adler
Comment 14 2020-05-09 16:34:53 PDT
(In reply to Sam Weinig from comment #13) > (In reply to Darin Adler from comment #12) > > I was just working on replacing WTF::Optional with std::optional. > > Sure. That's the right thing to do now. All I meant that I we brought those > in before we had a copy in the standard library we could use. Sure, I understood that. I was sort of observing the flow of the tides in and back out.
Note You need to log in before you can comment on or make changes to this bug.