Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: 353a203b0b4c5c758073d49979f100c4f354ed53
      
https://github.com/WebKit/WebKit/commit/353a203b0b4c5c758073d49979f100c4f354ed53
  Author: Darin Adler <[email protected]>
  Date:   2024-04-09 (Tue, 09 Apr 2024)

  Changed paths:
    M Source/JavaScriptCore/API/JSStringRef.cpp
    M Source/JavaScriptCore/wasm/WasmFormat.cpp
    M Source/JavaScriptCore/wasm/WasmName.h
    M Source/JavaScriptCore/wasm/WasmParser.h
    M Source/JavaScriptCore/wasm/WasmSectionParser.cpp
    M Source/JavaScriptCore/wasm/js/JSWebAssemblyInstance.cpp
    M Source/JavaScriptCore/wasm/js/JSWebAssemblyModule.cpp
    M Source/JavaScriptCore/wasm/js/WebAssemblyModuleConstructor.cpp
    M Source/JavaScriptCore/wasm/js/WebAssemblyModuleRecord.cpp
    M Source/WTF/wtf/text/AtomStringImpl.cpp
    M Source/WTF/wtf/text/StringConcatenate.h
    M Source/WTF/wtf/text/WTFString.cpp
    M Source/WTF/wtf/unicode/UTF8Conversion.cpp
    M Source/WTF/wtf/unicode/UTF8Conversion.h
    M Source/WebCore/workers/ScriptBuffer.cpp
    M Source/WebCore/xml/XSLTProcessorLibxslt.cpp

  Log Message:
  -----------
  Use std::span and char8_t for UTF-8
https://bugs.webkit.org/show_bug.cgi?id=271527
rdar://problem/125298503

Reviewed by Chris Dumez.

An advantage of using char8_t is that it expresses the fact that
the characters are UTF-8, so we can just use std::span<char8_t>
instead of things like FromUTF8. Also, makeString never returns
a null string, which turns out to be what many of these callers
want, so we save code.

* Source/JavaScriptCore/API/JSStringRef.cpp:
(JSStringCreateWithUTF8CString): Cast to char8_t.

* Source/JavaScriptCore/wasm/WasmFormat.cpp:
(JSC::Wasm::makeString): Use makeString instead of String::fromUTF8.

* Source/JavaScriptCore/wasm/WasmName.h: Use char8_t.

* Source/JavaScriptCore/wasm/WasmParser.h:
(JSC::Wasm::Parser::fail const): Remove unneeded call to String::number.
(JSC::Wasm::Parser<SuccessType>::consumeUTF8String): Use span and
spanReinterpretCast<const char8_t>.

* Source/JavaScriptCore/wasm/WasmSectionParser.cpp:
(JSC::Wasm::SectionParser::parseExport): Use makeString instead of
String::fromUTF8.

* Source/JavaScriptCore/wasm/js/JSWebAssemblyInstance.cpp:
(JSC::JSWebAssemblyInstance::tryCreate): Use makeAtomString instead of
String::fromUTF8.
* Source/JavaScriptCore/wasm/js/JSWebAssemblyModule.cpp:
(JSC::JSWebAssemblyModule::finishCreation): Ditto.

* Source/JavaScriptCore/wasm/js/WebAssemblyModuleConstructor.cpp:
(JSC::webAssemblyModuleCustomSections): Use makeString instead of
String::fromUTF8.
* Source/JavaScriptCore/wasm/js/WebAssemblyModuleRecord.cpp:
(JSC::WebAssemblyModuleRecord::finishCreation): Ditto.
(JSC::WebAssemblyModuleRecord::initializeImports): Take advantage of
the fact that makeString already handles this without calling
String::UTF8, and call makeAtomString instead of String::fromUTF8..
(JSC::WebAssemblyModuleRecord::initializeExports): Ditto.

* Source/WTF/wtf/text/AtomStringImpl.cpp:
(WTF::HashAndUTF8CharactersTranslator::translate): Cast to char8_t.

* Source/WTF/wtf/text/StringConcatenate.h: Renamed FromUTF8 to UTF8Adapter
since there is little need to use it directly any more. Use char8_t instead
of char. Added a specialization for span<char8_t> that uses the UTF8Adapter.

* Source/WTF/wtf/text/WTFString.cpp:
(WTF::fromUTF8Impl): Use spanReinterpretCast<const char8_t>.

* Source/WTF/wtf/unicode/UTF8Conversion.cpp:
(WTF::Unicode::convertUTF8ToUTF16Impl): Use std::span<const char8_t>.
(WTF::Unicode::convertUTF8ToUTF16): Ditto.
(WTF::Unicode::convertUTF8ToUTF16ReplacingInvalidSequences): Ditto.
(WTF::Unicode::computeUTFLengths): Ditto.
* Source/WTF/wtf/unicode/UTF8Conversion.h: Ditto.

* Source/WebCore/workers/ScriptBuffer.cpp:
(WebCore::ScriptBuffer::toString const): Use
spanReinterpretCast<const char8_t>.

* Source/WebCore/xml/XSLTProcessorLibxslt.cpp:
(WebCore::writeToStringBuilder): Update to use UTF8Adapter.

Canonical link: https://commits.webkit.org/277249@main



To unsubscribe from these emails, change your notification settings at 
https://github.com/WebKit/WebKit/settings/notifications
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to