Use std::span and char8_t for UTF-8#26377
Merged
webkit-commit-queue merged 1 commit intoWebKit:mainfrom Apr 9, 2024
Merged
Conversation
Collaborator
|
EWS run on previous version of this PR (hash be863f2) Details |
be863f2 to
4ac008d
Compare
Collaborator
|
EWS run on previous version of this PR (hash 4ac008d) Details |
4ac008d to
978b196
Compare
Collaborator
|
EWS run on current version of this PR (hash 978b196) Details |
Member
Author
|
I'm not sure why EWS doesn't show it but this is working and passing all the tests. Ready for review. I am a little surprised you didn't review already, @cdumez. |
Contributor
On it. The last time I looked EWS was red and then I got side-tracked. |
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
978b196 to
353a203
Compare
Collaborator
|
Committed 277249@main (353a203): https://commits.webkit.org/277249@main Reviewed commits have been landed. Closing PR #26377 and removing active labels. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
🛠 wpe
353a203
978b196
🧪 api-mac🧪 mac-wk1🧪 mac-wk2