Simplify valueToUSVString
Created attachment 285479 [details] Patch
Note that the String::find function calls its function on each code unit, not each code point, so it can't be used to find unpaired surrogates. Instead it was finding all surrogates.
Comment on attachment 285479 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=285479&action=review > Source/WebCore/bindings/js/JSDOMBinding.cpp:141 > + bool foundUnpairedSurrogate = false; > + for (auto codePoint : view.codePoints()) { > + if (U_IS_SURROGATE(codePoint)) { > + foundUnpairedSurrogate = true; > + break; > + } > + } > + if (!foundUnpairedSurrogate) > + return string; Or I could write a StringView::contains that takes a function that takes a UChar32 and have it iterate code points to remove this loop from this function. To do that I would presumably rename CharacterMatchFunction to CodeUnitMatchFunction and then add a CodePointMatchFunction type. But function pointers are inefficient. I wonder if there is a simple way to write a version that will inline the lambda that is passed in. (Strangely I noticed we have both CharacterMatchFunction in StringView.h and CharacterMatchFunctionPtr in StringImpl.h. We also have a function named stripWhiteSpace that strips arbitrary code units and simplifyWhiteSpace that "simplifies" arbitrary code units. Needs some cleanup I think.)
Comment on attachment 285479 [details] Patch Clearing flags on attachment: 285479 Committed r204228: <http://trac.webkit.org/changeset/204228>
All reviewed patches have been landed. Closing bug.