Update String::containsOnlyASCII() to handle 8 bits strings
Created attachment 117845 [details] Patch
Comment on attachment 117845 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=117845&action=review > Source/JavaScriptCore/wtf/text/WTFString.h:504 > + if (is8Bit()) { > + const LChar* characters = characters8(); > + LChar ored = 0; > + for (size_t i = 0; i < m_impl->length(); ++i) > + ored |= characters[i]; > + return !(ored & 0x80); > + } It would probably make sense to add a charactersAreAllASCII that takes LChars, to match the one that takes UChars, and call it here.
Created attachment 117946 [details] Patch
Comment on attachment 117946 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=117946&action=review > Source/JavaScriptCore/wtf/text/WTFString.h:492 > return !(ored & 0xFF80); This is the only thing here that is specific to 2 bytes. It could be written like this: return !(ored & ~0x7F); And then it would only require that CharType was the size of an integer or smaller. Or it could be written like this: CharType lowBits = 0x7F; return !(ored & ~lowBits); And then it would work with pretty much any type and a COMPILE_ASSERT would not be needed.
I like that. Thanks for the review.
Committed r102059: <http://trac.webkit.org/changeset/102059>