New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weβll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Setting the value of a textarea is much slower in WebKit than it is in Chromium #6411
Conversation
EWS run on current version of this PR (hash 2d6c86c) |
@@ -447,6 +447,35 @@ int codePointCompare(StringView lhs, StringView rhs) | |||
return codePointCompare(lhs.characters16(), lhs.length(), rhs.characters16(), rhs.length()); | |||
} | |||
|
|||
template<typename CharacterType> static String makeStringBySimplifyingNewLinesSlowCase(const String& string, unsigned firstCarriageReturn) | |||
{ | |||
unsigned length = string.length(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
May be worth ASSERTing some sanity for firstCarriageReturn
. Chances are this function is so much of a special case that no one will ever try to misuse it, so not feeling strongly about the need for sanity checks.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I feel comfortable leaving this as is.
auto result = String::createUninitialized(length, resultCharacters); | ||
memcpy(resultCharacters, characters, firstCarriageReturn * sizeof(CharacterType)); | ||
for (unsigned i = firstCarriageReturn; i < length; ++i) { | ||
if (characters[i] != '\r') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have a slight concern about whether the existing function implemented the correct algorithm. Do we know for certain what normalization is supposed to be done? I've seen some weird newline combinations in the past (\n\r
, \r\r\n
are treated as a single newline by some software).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am certain the function is doing the correct normalization. I researched this originally and still remember learning this was exactly what is needed.
β¦n Chromium https://bugs.webkit.org/show_bug.cgi?id=247739 rdar://problem/102218029 Reviewed by Alexey Proskuryakov. These changes make the micro-benchmark of setting the text of a textarea about 4x faster. * Source/WTF/wtf/text/StringView.cpp: (WTF::makeStringBySimplifyingNewLinesSlowCase): Added. Implements a faster algorithm for standardizing line endings as opposed to making two passes through the string. * Source/WTF/wtf/text/StringView.h: (WTF::makeStringBySimplifyingNewLines): Added a high-speed check for '\r' characters before doing the slower algorithm to standardize line separators. Most strings won't have any at all, and none of the ones in the benchmark do. Canonical link: https://commits.webkit.org/256596@main
2d6c86c
to
610bbdb
Compare
Committed 256596@main (610bbdb): https://commits.webkit.org/256596@main Reviewed commits have been landed. Closing PR #6411 and removing active labels. |
610bbdb
2d6c86c
π π§ͺ winπ wincairoπ§ͺ ios-wk2π§ͺ api-iosπ π§ͺ jscπ§ͺ mac-wk1π§ͺ mac-AS-debug-wk2