DescriptionExpand WTF::StringView's API to be more like StringPiece.
StringView no longer owns the string passed into it, and can now wrap
a raw ptr to some characters.
This allows us to leverage the inline strlen optimization where the
compiler will embed the length of literal strings into the binary. It
also allows the deletion many overloaded methods that used to take
an LChar*, UChar* or String and can now just take a StringView instead.
For example the two constructors in TextRun are now a single one that
takes a StringView. This needed to be done in this patch to avoid
ambiguous constructors.
Future patches will replace CSSParserString with StringView, and also
vastly simplify the huge number of overloads on various methods. We'll
also expand the API surface of StringView to include the many useful
operations that StringPiece has.
This was originally committed as:
https://crrev.com/330deea56e27bc760fa52101040a51428bb7f582 but was
reverted due an incorrect assert in the
StringView(const UChar*, unsigned length) constructor. The assert
was incorrectly calling lengthOfNullTerminatedString on the UChar
in the assert, but this constructor is used for byte sequences which
are not null terminated.
BUG=615174
Committed: https://crrev.com/9b0aad1eca55ac75f437789514224e9b922fe514
Cr-Commit-Position: refs/heads/master@{#396942}
Patch Set 1 #Patch Set 2 : Make it non-owning. #Patch Set 3 : Null StringView. #Patch Set 4 : Try again. #Patch Set 5 : fix typo for length access. #
Total comments: 11
Patch Set 6 : haraken@ review. #Patch Set 7 : Don't assert about strlen for length specific constructor. #Patch Set 8 : Add a lot of tests, fix a bunch of bugs. #
Total comments: 2
Patch Set 9 : Don't treat characters8() or characters16() like they're null terminated. #Patch Set 10 : Move the constructors into StringView.h #Patch Set 11 : clean up comments. #Patch Set 12 : Add comments. #Patch Set 13 : Remove bad assert. #Messages
Total messages: 60 (24 generated)
|