Ignore:
Timestamp:
Aug 18, 2019, 8:12:19 AM (6 years ago)
Author:
Darin Adler
Message:

Tidy up checks to see if a character is in the Latin-1 range by using isLatin1 consistently
https://bugs.webkit.org/show_bug.cgi?id=200861

Reviewed by Ross Kirsling.

Source/JavaScriptCore:

  • parser/Lexer.cpp:

(JSC::Lexer<T>::record8): Use isLatin1.
(JSC::assertCharIsIn8BitRange): Deleted. Can just assert isLatin1 directly.
(JSC::Lexer<T>::append8): Assert isLatin1 directly.
(JSC::characterRequiresParseStringSlowCase): Use isLatin1.

  • parser/Lexer.h:

(JSC::Lexer<UChar>::isWhiteSpace): Ditto.

  • runtime/LiteralParser.cpp:

(JSC::LiteralParser<CharType>::Lexer::lex): Ditto.
(JSC::isSafeStringCharacter): Ditto.

  • runtime/Identifier.cpp:

(JSC::Identifier::add8): Ditto.

  • runtime/LiteralParser.cpp:

(JSC::isSafeStringCharacter): Ditto.

  • runtime/StringPrototype.cpp:

(JSC::stringProtoFuncRepeatCharacter): Ditto.

  • yarr/YarrJIT.cpp:

(JSC::Yarr::YarrGenerator::generatePatternCharacterOnce): Ditto.
(JSC::Yarr::YarrGenerator::generatePatternCharacterGreedy): Ditto.
(JSC::Yarr::YarrGenerator::backtrackPatternCharacterNonGreedy): Ditto.

Source/WebCore:

  • css/makeSelectorPseudoClassAndCompatibilityElementMap.py: Use isLatin1.
  • css/makeSelectorPseudoElementsMap.py: Ditto.
  • editing/TextIterator.cpp:

(WebCore::isNonLatin1Separator): Ditto.
(WebCore::isSeparator): Ditto.

  • platform/network/HTTPParsers.cpp:

(WebCore::isValidReasonPhrase): Ditto.
(WebCore::isValidHTTPHeaderValue): Ditto.
(WebCore::isValidAcceptHeaderValue): Ditto.

  • platform/text/TextCodecLatin1.cpp:

(WebCore::TextCodecLatin1::decode): Ditto.

  • platform/text/TextCodecUTF8.cpp:

(WebCore::TextCodecUTF8::handlePartialSequence): Ditto.
(WebCore::TextCodecUTF8::decode): Ditto.

Source/WebKitLegacy/mac:

  • Misc/WebKitNSStringExtras.mm:

(canUseFastRenderer): Use isLatin1.

Source/WTF:

  • wtf/text/StringBuilder.cpp:

(WTF::StringBuilder::appendCharacters): Use isLatin1 and also call append rather than
calling appendCharacters, since it's the same thing, inlined, and removes the need for
a local variable. Also tweaked the idiom of the code using memcpy.
(WTF::StringBuilder::canShrink const): Reworded a comment.

  • wtf/text/StringBuilder.h:

(WTF::StringBuilder::append): Use isLatin1.

  • wtf/text/StringCommon.h:

(WTF::isLatin1): Moved this function template here so it can be used here.
(WTF::find): Use isLatin1.

  • wtf/text/StringImpl.h:

(WTF::isLatin1): Deleted. Moved to StringCommon.h.
(WTF::reverseFind): Use isLatin1.
(WTF::isSpaceOrNewline): Ditto.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/parser/Lexer.cpp

    r248829 r248831  
    851851inline void Lexer<T>::record8(int c)
    852852{
    853     ASSERT(c >= 0);
    854     ASSERT(c <= 0xFF);
     853    ASSERT(isLatin1(c));
    855854    m_buffer8.append(static_cast<LChar>(c));
    856 }
    857 
    858 template <typename T>
    859 inline void assertCharIsIn8BitRange(T c)
    860 {
    861     UNUSED_PARAM(c);
    862     ASSERT(c >= 0);
    863     ASSERT(c <= 0xFF);
    864 }
    865 
    866 template <>
    867 inline void assertCharIsIn8BitRange(UChar c)
    868 {
    869     UNUSED_PARAM(c);
    870     ASSERT(c <= 0xFF);
    871 }
    872 
    873 template <>
    874 inline void assertCharIsIn8BitRange(LChar)
    875 {
    876855}
    877856
     
    885864    for (size_t i = 0; i < length; i++) {
    886865        T c = p[i];
    887         assertCharIsIn8BitRange(c);
     866        ASSERT(isLatin1(c));
    888867        rawBuffer[i] = c;
    889868    }
     
    11611140static ALWAYS_INLINE bool characterRequiresParseStringSlowCase(UChar character)
    11621141{
    1163     return character < 0xE || character > 0xFF;
     1142    return character < 0xE || !isLatin1(character);
    11641143}
    11651144
Note: See TracChangeset for help on using the changeset viewer.