Bug 211656

Summary: Streamline MarkupAccumulator to improve efficiency a bit
Product: WebKit Reporter: Darin Adler <darin>
Component: HTML EditingAssignee: Darin Adler <darin>
Status: RESOLVED FIXED    
Severity: Normal CC: andersca, benjamin, cdumez, changseok, cmarcelo, dbarton, dino, esprehn+autocc, ews-watchlist, fmalita, fred.wang, glenn, gyuyoung.kim, keith_miller, kondapallykalyan, mark.lam, mifenton, mmaxfield, msaboff, pdr, saam, sabouhallawa, sam, schenney, sergio, tzagallo, webkit-bug-importer, wenson_hsieh
Priority: P2 Keywords: InRadar
Version: WebKit Nightly Build   
Hardware: All   
OS: All   
Attachments:
Description Flags
Patch
none
Patch
none
Patch andersca: review+

Description Darin Adler 2020-05-08 19:27:26 PDT
Streamline MarkupAccumulator to improve efficiency a bit
Comment 1 Darin Adler 2020-05-08 19:49:07 PDT Comment hidden (obsolete)
Comment 2 Darin Adler 2020-05-08 23:47:28 PDT Comment hidden (obsolete)
Comment 3 Darin Adler 2020-05-09 06:35:40 PDT Comment hidden (obsolete)
Comment 4 Darin Adler 2020-05-09 07:30:25 PDT
Created attachment 398926 [details]
Patch
Comment 5 Anders Carlsson 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?
Comment 6 Darin Adler 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.
Comment 7 Darin Adler 2020-05-09 08:56:28 PDT
Also, I will need to fix the crash seen on mac-debug!
Comment 8 Darin Adler 2020-05-09 08:57:55 PDT
Ah, got the null check wrong.
Comment 9 Darin Adler 2020-05-09 09:04:05 PDT
Committed r261437: <https://trac.webkit.org/changeset/261437>
Comment 10 Radar WebKit Bug Importer 2020-05-09 09:05:17 PDT
<rdar://problem/63054009>
Comment 11 Sam Weinig 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>.
Comment 12 Darin Adler 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.
Comment 13 Sam Weinig 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.
Comment 14 Darin Adler 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.