-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weβll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Drop String constructors taking in a raw pointer and a length #26611
Drop String constructors taking in a raw pointer and a length #26611
Conversation
EWS run on previous version of this PR (hash c722130) |
c722130
to
f44ad2e
Compare
EWS run on previous version of this PR (hash f44ad2e) |
f44ad2e
to
b6b64bf
Compare
EWS run on previous version of this PR (hash b6b64bf) |
b6b64bf
to
0a89c33
Compare
EWS run on previous version of this PR (hash 0a89c33) |
0a89c33
to
4010db3
Compare
EWS run on previous version of this PR (hash 4010db3) |
4010db3
to
f0bab7a
Compare
EWS run on previous version of this PR (hash f0bab7a) |
f0bab7a
to
4d38a27
Compare
EWS run on previous version of this PR (hash 4d38a27) |
4d38a27
to
ab9e724
Compare
EWS run on previous version of this PR (hash ab9e724) |
@@ -131,7 +131,7 @@ String LazyJSValue::tryGetString(Graph& graph) const | |||
return u.stringImpl; | |||
|
|||
case SingleCharacterString: | |||
return String(&u.character, 1); | |||
return String(span(u.character)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need String()
here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We do not.
@@ -43,7 +43,7 @@ static String readFileIntoString(const char* fileName) | |||
size_t readSize = fread(buffer.data(), 1, buffer.size(), file); | |||
fclose(file); | |||
RELEASE_ASSERT(readSize == buffer.size()); | |||
return String(buffer.data(), buffer.size()); | |||
return String(buffer.span()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need String()
here?
βI also think String::createUninitialized
would allow us to do this without two copies. And there should be a helper function version of this, not written out here.
@@ -340,7 +340,7 @@ JSValue IntlDisplayNames::of(JSGlobalObject* globalObject, JSValue codeValue) co | |||
// uldn_localeDisplayName, uldn_regionDisplayName, and uldn_scriptDisplayName return U_ILLEGAL_ARGUMENT_ERROR if the display-name is not found. | |||
// We should return undefined if fallback is "none". Otherwise, we should return input value. | |||
if (status == U_ILLEGAL_ARGUMENT_ERROR) | |||
return (m_fallback == Fallback::None) ? jsUndefined() : jsString(vm, String(canonicalCode.data(), canonicalCode.length())); | |||
return (m_fallback == Fallback::None) ? jsUndefined() : jsString(vm, String(canonicalCode.span())); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe we can omit String()
here?
@@ -457,7 +457,7 @@ const String& IntlLocale::language() | |||
Vector<char, 8> buffer; | |||
auto status = callBufferProducingFunction(uloc_getLanguage, m_localeID.data(), buffer); | |||
ASSERT_UNUSED(status, U_SUCCESS(status)); | |||
m_language = String(buffer.data(), buffer.size()); | |||
m_language = String(buffer.span()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we omit String()
here?
@@ -469,7 +469,7 @@ const String& IntlLocale::script() | |||
Vector<char, 4> buffer; | |||
auto status = callBufferProducingFunction(uloc_getScript, m_localeID.data(), buffer); | |||
ASSERT_UNUSED(status, U_SUCCESS(status)); | |||
m_script = String(buffer.data(), buffer.size()); | |||
m_script = String(buffer.span()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we omit String()
here?
@@ -224,7 +224,7 @@ static String unmodifiedTextFromEvent(WPARAM wparam, WebEventType type) | |||
return String(); | |||
|
|||
UChar c = static_cast<UChar>(wparam); | |||
return String(&c, 1); | |||
return String(span(c)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can omit String()
here.
@@ -1172,7 +1172,7 @@ HTTPServer server([receivedFirstConnection = false] (Connection connection) muta | |||
String longString(LChar c) | |||
{ | |||
Vector<LChar> vector(length, c); | |||
return String(vector.data(), length); | |||
return String(vector.span()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can omit String()
here.
@@ -268,7 +268,7 @@ | |||
String longString(LChar c) | |||
{ | |||
Vector<LChar> vector(length, c); | |||
return String(vector.data(), length); | |||
return String(vector.span()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can omit String()
here.
@@ -375,15 +375,15 @@ static void appendUTF8ToVector(Vector<uint8_t>& vector, const String& string) | |||
pathPrefixLength = strlen(postPathPrefix); | |||
ASSERT_WITH_MESSAGE(pathPrefixLength, "HTTPServer assumes request is GET or POST"); | |||
size_t pathLength = pathEnd - request.data() - pathPrefixLength; | |||
return String(request.data() + pathPrefixLength, pathLength); | |||
return String(request.subspan(pathPrefixLength, pathLength)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can omit String()
here.
} | ||
|
||
String HTTPServer::parseBody(const Vector<char>& request) | ||
{ | ||
const char* headerEndBytes = "\r\n\r\n"; | ||
const char* headerEnd = strnstr(request.data(), headerEndBytes, request.size()) + strlen(headerEndBytes); | ||
size_t headerLength = headerEnd - request.data(); | ||
return String(headerEnd, request.size() - headerLength); | ||
return String(request.subspan(headerLength)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can omit String()
here.
9a4c7dc
to
4428010
Compare
4428010
to
a483215
Compare
EWS run on previous version of this PR (hash a483215)
|
a483215
to
e949a4f
Compare
EWS run on current version of this PR (hash e949a4f)
|
https://bugs.webkit.org/show_bug.cgi?id=271888 Reviewed by Darin Adler. Drop String constructors taking in a raw pointer and a length, in favor of the ones taking in a std::span. * Source/JavaScriptCore/API/OpaqueJSString.h: (OpaqueJSString::OpaqueJSString): * Source/JavaScriptCore/API/tests/JSONParseTest.cpp: (testJSONParse): * Source/JavaScriptCore/dfg/DFGLazyJSValue.cpp: (JSC::DFG::LazyJSValue::tryGetString const): * Source/JavaScriptCore/parser/Lexer.cpp: (JSC::Lexer<CharacterType>::parseCommentDirectiveValue): * Source/JavaScriptCore/runtime/FuzzerPredictions.cpp: (JSC::readFileIntoString): * Source/JavaScriptCore/runtime/IntlCollator.cpp: (JSC::IntlCollator::sortLocaleData): (JSC::IntlCollator::checkICULocaleInvariants): * Source/JavaScriptCore/runtime/IntlDateTimeFormat.cpp: (JSC::IntlDateTimeFormat::localeData): * Source/JavaScriptCore/runtime/IntlDisplayNames.cpp: (JSC::IntlDisplayNames::of const): * Source/JavaScriptCore/runtime/IntlDurationFormat.cpp: (JSC::retrieveSeparator): * Source/JavaScriptCore/runtime/IntlLocale.cpp: (JSC::IntlLocale::language): (JSC::IntlLocale::script): (JSC::IntlLocale::region): (JSC::IntlLocale::calendars): (JSC::IntlLocale::collations): (JSC::IntlLocale::timeZones): * Source/JavaScriptCore/runtime/IntlNumberFormat.cpp: (JSC::IntlNumberFormat::formatRange const): * Source/JavaScriptCore/runtime/IntlObject.cpp: (JSC::languageTagForLocaleID): (JSC::intlAvailableCalendars): (JSC::availableCollations): (JSC::availableCurrencies): (JSC::availableNumberingSystems): (JSC::intlAvailableTimeZones): * Source/JavaScriptCore/runtime/IntlPluralRules.cpp: (JSC::IntlPluralRules::resolvedOptions const): * Source/JavaScriptCore/runtime/JSImmutableButterfly.cpp: (JSC::JSImmutableButterfly::createFromString): * Source/JavaScriptCore/runtime/JSONObject.cpp: (JSC::gap): (JSC::FastStringifier<CharType>::result const): * Source/JavaScriptCore/runtime/LiteralParser.cpp: (JSC::LiteralParser<CharType>::makeJSString): * Source/JavaScriptCore/runtime/NumberPrototype.cpp: (JSC::toStringWithRadixInternal): * Source/JavaScriptCore/tools/FunctionAllowlist.cpp: (JSC::FunctionAllowlist::FunctionAllowlist): * Source/JavaScriptCore/tools/FunctionOverrides.cpp: (JSC::parseClause): * Source/JavaScriptCore/wasm/WasmIndexOrName.cpp: (JSC::Wasm::makeString): * Source/WTF/wtf/URLHelpers.cpp: (WTF::URLHelpers::mapHostName): * Source/WTF/wtf/UUID.cpp: (WTF::bootSessionUUIDString): * Source/WTF/wtf/text/StringView.h: (WTF::StringView::toString const): * Source/WTF/wtf/text/WTFString.cpp: (WTF::String::String): (WTF::String::fromCodePoint): * Source/WTF/wtf/text/WTFString.h: (WTF::IntegerToStringConversionTrait<String>::flush): (WTF::StringLiterals::operator _str): * Source/WebCore/Modules/encryptedmedia/InitDataRegistry.cpp: (WebCore::extractKeyIDsKeyids): * Source/WebCore/Modules/websockets/WebSocketExtensionParser.cpp: (WebCore::WebSocketExtensionParser::consumeToken): * Source/WebCore/PAL/pal/text/TextCodecReplacement.cpp: (PAL::TextCodecReplacement::decode): * Source/WebCore/accessibility/AccessibilityMathMLElement.cpp: (WebCore::AccessibilityMathMLElement::textUnderElement const): * Source/WebCore/bindings/js/SerializedScriptValue.cpp: (WebCore::CloneDeserializer::readString): * Source/WebCore/crypto/SubtleCrypto.cpp: (WebCore::SubtleCrypto::unwrapKey): * Source/WebCore/css/CSSCounterStyle.cpp: (WebCore::counterForSystemCJK): (WebCore::CSSCounterStyle::counterForSystemEthiopicNumeric): * Source/WebCore/css/process-css-properties.py: (GenerateCSSPropertyNames): * Source/WebCore/editing/Editing.cpp: (WebCore::nonBreakingSpaceString): * Source/WebCore/fileapi/FileReaderLoader.cpp: (WebCore::FileReaderLoader::stringResult): * Source/WebCore/html/FTPDirectoryDocument.cpp: (WebCore::FTPDirectoryDocumentParser::appendEntry): (WebCore::FTPDirectoryDocumentParser::loadDocumentTemplate): * Source/WebCore/html/TypeAhead.cpp: (WebCore::TypeAhead::handleEvent): * Source/WebCore/html/parser/AtomHTMLToken.h: (WebCore::AtomHTMLToken::AtomHTMLToken): * Source/WebCore/html/parser/CSSPreloadScanner.cpp: (WebCore::parseCSSStringOrURL): * Source/WebCore/html/parser/HTMLDocumentParserFastPath.cpp: (WebCore::HTMLFastPathParser::scanText): * Source/WebCore/html/parser/HTMLEntityParser.cpp: (WebCore::SegmentedStringSource::pushBackButKeep): * Source/WebCore/html/parser/HTMLInputStream.h: (WebCore::HTMLInputStream::markEndOfFile): * Source/WebCore/html/shadow/DateTimeNumericFieldElement.cpp: (WebCore::DateTimeNumericFieldElement::handleKeyboardEvent): * Source/WebCore/html/track/VTTScanner.cpp: (WebCore::VTTScanner::extractString): * Source/WebCore/html/track/VTTScanner.h: * Source/WebCore/html/track/WebVTTTokenizer.cpp: (WebCore::WebVTTTokenizer::WebVTTTokenizer): * Source/WebCore/inspector/InspectorStyleSheet.cpp: (WebCore::fixUnparsedProperties): * Source/WebCore/layout/formattingContexts/inline/display/InlineDisplayContentBuilder.cpp: (WebCore::Layout::InlineDisplayContentBuilder::appendTextDisplayBox): * Source/WebCore/loader/FTPDirectoryParser.cpp: (WebCore::parseOneFTPLine): * Source/WebCore/loader/FormSubmission.cpp: (WebCore::appendMailtoPostFormDataToURL): * Source/WebCore/loader/LinkHeader.cpp: (WebCore::findURLBoundaries): (WebCore::parseParameterValue): * Source/WebCore/loader/ResourceCryptographicDigest.cpp: (WebCore::parseCryptographicDigestImpl): (WebCore::parseEncodedCryptographicDigestImpl): * Source/WebCore/loader/appcache/ApplicationCacheManifestParser.cpp: (WebCore::makeManifestURL): * Source/WebCore/loader/appcache/ApplicationCacheStorage.cpp: (WebCore::parseHeader): * Source/WebCore/page/EventSource.cpp: (WebCore::EventSource::dispatchMessageEvent): * Source/WebCore/page/csp/ContentSecurityPolicy.cpp: (WebCore::ContentSecurityPolicy::didReceiveHeader): * Source/WebCore/page/csp/ContentSecurityPolicyDirectiveList.cpp: (WebCore::ContentSecurityPolicyDirectiveList::parseDirective): (WebCore::ContentSecurityPolicyDirectiveList::parseRequireTrustedTypesFor): * Source/WebCore/page/csp/ContentSecurityPolicyMediaListDirective.cpp: (WebCore::ContentSecurityPolicyMediaListDirective::parse): * Source/WebCore/page/csp/ContentSecurityPolicySourceList.cpp: (WebCore::ContentSecurityPolicySourceList::parse): (WebCore::ContentSecurityPolicySourceList::parsePath): (WebCore::ContentSecurityPolicySourceList::parseNonceSource): * Source/WebCore/page/csp/ContentSecurityPolicyTrustedTypesDirective.cpp: (WebCore::ContentSecurityPolicyTrustedTypesDirective::parse): * Source/WebCore/platform/cocoa/KeyEventCocoa.mm: (WebCore::keyForCharCode): * Source/WebCore/platform/encryptedmedia/CDMUtilities.cpp: (WebCore::CDMUtilities::parseJSONObject): * Source/WebCore/platform/graphics/FontCascade.h: (WebCore::FontCascade::widthOfSpaceString const): * Source/WebCore/platform/graphics/StringTruncator.cpp: (WebCore::truncateString): * Source/WebCore/platform/graphics/TextRun.h: (WebCore::TextRun::isolatedCopy const): * Source/WebCore/platform/graphics/angle/GraphicsContextGLANGLE.cpp: (WebCore::GraphicsContextGLANGLE::getActiveAttribImpl): (WebCore::GraphicsContextGLANGLE::getActiveUniformImpl): (WebCore::GraphicsContextGLANGLE::getProgramInfoLog): (WebCore::GraphicsContextGLANGLE::getShaderInfoLog): (WebCore::GraphicsContextGLANGLE::getActiveUniformBlockName): (WebCore::GraphicsContextGLANGLE::getTransformFeedbackVarying): (WebCore::GraphicsContextGLANGLE::getTranslatedShaderSourceANGLE): * Source/WebCore/platform/graphics/avfoundation/CDMFairPlayStreaming.cpp: (WebCore::extractSinfData): (WebCore::CDMPrivateFairPlayStreaming::extractKeyIDsMpts): * Source/WebCore/platform/graphics/avfoundation/MediaPlayerPrivateAVFoundation.cpp: (WebCore::MediaPlayerPrivateAVFoundation::extractKeyURIKeyIDAndCertificateFromInitData): * Source/WebCore/platform/graphics/avfoundation/objc/CDMInstanceFairPlayStreamingAVFObjC.mm: (WebCore::parseJSONValue): * Source/WebCore/platform/graphics/cocoa/FontPlatformDataCocoa.mm: (WebCore::FontPlatformData::variationAxes const): * Source/WebCore/platform/graphics/cocoa/SourceBufferParserWebM.cpp: (WebCore::WebMParser::OnTrackEntry): * Source/WebCore/platform/network/HTTPHeaderMap.cpp: (WebCore::HTTPHeaderMap::set): * Source/WebCore/platform/network/HTTPParsers.cpp: (WebCore::trimInputSample): (WebCore::parseHTTPHeader): * Source/WebCore/platform/network/RFC8941.cpp: (RFC8941::parseToken): * Source/WebCore/platform/text/SegmentedString.cpp: (WebCore::SegmentedString::advancePastSlowCase): * Source/WebCore/rendering/RenderCombineText.cpp: (WebCore::RenderCombineText::combineTextIfNeeded): * Source/WebCore/rendering/RenderFileUploadControl.cpp: (WebCore::RenderFileUploadControl::computeIntrinsicLogicalWidths const): * Source/WebCore/rendering/RenderListMarker.cpp: (WebCore::RenderListMarker::textRun const): * Source/WebCore/rendering/RenderTextControl.cpp: (WebCore::RenderTextControl::getAverageCharWidth): * Source/WebCore/rendering/svg/SVGTextMetrics.cpp: (WebCore::SVGTextMetrics::SVGTextMetrics): * Source/WebCore/svg/SVGParserUtilities.cpp: (WebCore::parseGlyphName): (WebCore::parseKerningUnicodeString): * Source/WebCore/svg/SVGStringList.cpp: (WebCore::SVGStringList::parse): * Source/WebCore/svg/SVGToOTFFontConversion.cpp: (WebCore::codepointToString): * Source/WebCore/svg/SVGViewSpec.cpp: (WebCore::SVGViewSpec::parseViewSpec): * Source/WebCore/testing/MockCDMFactory.cpp: (WebCore::MockCDMInstanceSession::updateLicense): * Source/WebKit/UIProcess/API/APIContentRuleListStore.cpp: (API::getContentRuleListSourceFromMappedFile): * Source/WebKit/UIProcess/Cocoa/WebPasteboardProxyCocoa.mm: (WebKit::WebPasteboardProxy::testIPCSharedMemory): * Source/WebKit/UIProcess/mac/WebViewImpl.mm: (WebKit::commandNameForSelector): * Source/WebKit/WebProcess/Network/webrtc/LibWebRTCResolver.cpp: (WebKit::LibWebRTCResolver::start): * Source/WebKitLegacy/mac/WebView/WebHTMLView.mm: (commandNameForSelector): * Tools/DumpRenderTree/TestRunner.cpp: (TestRunner::runUIScript): * Tools/TestRunnerShared/UIScriptContext/UIScriptContext.cpp: (UIScriptContext::tryToCompleteUIScriptForCurrentParentCallback): * Tools/TestWebKitAPI/Tests/WTF/HexNumber.cpp: * Tools/TestWebKitAPI/Tests/WTF/NativePromise.cpp: (TestWebKitAPI::PhotoProducer::takePhotoImpl const): * Tools/TestWebKitAPI/Tests/WTF/StringBuilder.cpp: (TestWebKitAPI::expectBuilderContent): (TestWebKitAPI::TEST(StringBuilderTest, Append)): (TestWebKitAPI::TEST(StringBuilderTest, VariadicAppend)): * Tools/TestWebKitAPI/Tests/WTF/StringOperators.cpp: (TestWebKitAPI::TEST(WTF, ConcatenateCharacterArrayAndEmptyString)): * Tools/TestWebKitAPI/Tests/WTF/StringView.cpp: (TestWebKitAPI::TEST(WTF, StringViewContainsOnlyASCII)): * Tools/TestWebKitAPI/Tests/WTF/TextBreakIterator.cpp: (TestWebKitAPI::makeUTF16): * Tools/TestWebKitAPI/Tests/WTF/WTFString.cpp: (TestWebKitAPI::TEST(WTF, StringUnicodeEqualUCharArray)): * Tools/TestWebKitAPI/Tests/WTF/cocoa/URLExtras.mm: (TestWebKitAPI::TEST(WTF_URLExtras, URLExtras_ParsingError)): * Tools/TestWebKitAPI/Tests/WebCore/CBORReaderTest.cpp: (TestWebKitAPI::TEST(CBORReaderTest, TestReadStringWithNUL)): * Tools/TestWebKitAPI/Tests/WebCore/FileMonitor.cpp: (TestWebKitAPI::readContentsOfFile): * Tools/TestWebKitAPI/Tests/WebCore/SharedBuffer.cpp: (TestWebKitAPI::TEST_F): * Tools/TestWebKitAPI/Tests/WebKitCocoa/Download.mm: (longString): * Tools/TestWebKitAPI/Tests/WebKitCocoa/EventAttribution.mm: (TestWebKitAPI::signUnlinkableTokenAndSendSecretToken): * Tools/TestWebKitAPI/Tests/WebKitCocoa/ServiceWorkerBasic.mm: ((ServiceWorker, ExtensionServiceWorkerDisableCORS)): * Tools/TestWebKitAPI/Tests/WebKitCocoa/WKWebExtensionAPIWebNavigation.mm: (TestWebKitAPI::longString): * Tools/TestWebKitAPI/Tests/WebKitCocoa/WebPushDaemon.mm: * Tools/TestWebKitAPI/cocoa/HTTPServer.mm: (TestWebKitAPI::HTTPServer::parsePath): (TestWebKitAPI::HTTPServer::parseBody): * Tools/WebKitTestRunner/TestController.cpp: (WTR::TestController::createTestURL): Canonical link: https://commits.webkit.org/276859@main
e949a4f
to
c04fd9f
Compare
Committed 276859@main (c04fd9f): https://commits.webkit.org/276859@main Reviewed commits have been landed. Closing PR #26611 and removing active labels. |
c04fd9f
e949a4f
π§ͺ api-macπ§ͺ mac-wk1π π§ͺ jscπ§ͺ mac-wk2π gtk