Title: [292939] trunk/Source
Revision
292939
Author
cdu...@apple.com
Date
2022-04-15 21:44:41 -0700 (Fri, 15 Apr 2022)

Log Message

Leverage StringView in more places to avoid some String allocations
https://bugs.webkit.org/show_bug.cgi?id=239356

Reviewed by Darin Adler.

Source/_javascript_Core:

* inspector/ContentSearchUtilities.cpp:
(Inspector::ContentSearchUtilities::getRegularExpressionMatchesByLines):
(Inspector::ContentSearchUtilities::findMagicComment):
* runtime/ExceptionHelpers.cpp:
(JSC::invalidParameterInSourceAppender):
(JSC::invalidParameterInstanceofSourceAppender):
* runtime/IntlDateTimeFormat.cpp:
(JSC::IntlDateTimeFormat::formatToParts const):
(JSC::IntlDateTimeFormat::formatRangeToParts):
* runtime/IntlListFormat.cpp:
(JSC::IntlListFormat::formatToParts const):
* runtime/IntlNumberFormat.cpp:
(JSC::IntlNumberFormat::formatRangeToPartsInternal):
* tools/FunctionOverrides.cpp:
(JSC::initializeOverrideInfo):

Source/WebCore:

* Modules/fetch/FetchBodyConsumer.cpp:
(WebCore::FetchBodyConsumer::packageFormData):
* Modules/mediastream/libwebrtc/LibWebRTCRtpTransceiverBackend.cpp:
(WebCore::toRtpCodecCapability):
* Modules/model-element/scenekit/SceneKitModelLoader.mm:
(WebCore::mimeTypeUtilizingFileExtensionOverridingForLocalFiles):
* Modules/plugins/PluginReplacement.h:
(WebCore::ReplacementPlugin::supportsFileExtension const):
* Modules/plugins/YouTubePluginReplacement.cpp:
(WebCore::YouTubePluginReplacement::supportsFileExtension):
* Modules/plugins/YouTubePluginReplacement.h:
* animation/KeyframeEffect.cpp:
(WebCore::KeyframeEffect::setPseudoElement):
* css/ContainerQueryParser.cpp:
(WebCore::ContainerQueryParser::consumePlainSizeFeature):
* css/parser/CSSSelectorParser.cpp:
(WebCore::consumeANPlusB):
* dom/SecurityContext.cpp:
(WebCore::SecurityContext::parseSandboxPolicy):
* dom/SecurityContext.h:
* fileapi/ThreadableBlobRegistry.cpp:
(WebCore::isBlobURLContainsNullOrigin):
* html/DOMTokenList.cpp:
(WebCore::DOMTokenList::updateTokensFromAttributeValue):
* html/DOMTokenList.h:
* html/HTMLMapElement.cpp:
(WebCore::HTMLMapElement::parseAttribute):
* html/HTMLPlugInElement.cpp:
(WebCore::pluginReplacementForType):
* html/track/WebVTTParser.cpp:
(WebCore::WebVTTParser::checkAndCreateRegion):
(WebCore::WebVTTParser::checkAndStoreRegion):
(WebCore::WebVTTParser::checkStyleSheet):
(WebCore::WebVTTParser::checkAndStoreStyleSheet):
* html/track/WebVTTParser.h:
* inspector/InspectorStyleSheet.cpp:
(WebCore::StyleSheetHandler::observeProperty):
(WebCore::StyleSheetHandler::observeComment):
* layout/formattingContexts/inline/InlineLineBuilder.cpp:
(WebCore::Layout::toString):
* layout/formattingContexts/inline/display/InlineDisplayContentBuilder.cpp:
(WebCore::Layout::InlineDisplayContentBuilder::appendTextDisplayBox):
* layout/layouttree/LayoutInlineTextBox.h:
(WebCore::Layout::InlineTextBox::content const):
* loader/appcache/ApplicationCacheStorage.cpp:
(WebCore::ApplicationCacheStorage::store):
(WebCore::ApplicationCacheStorage::writeDataToUniqueFileInDirectory):
* loader/appcache/ApplicationCacheStorage.h:
* loader/cache/CachedSVGFont.cpp:
(WebCore::CachedSVGFont::getSVGFontById const):
(WebCore::CachedSVGFont::maybeInitializeExternalSVGFontElement):
* loader/cache/CachedSVGFont.h:
* page/Location.cpp:
(WebCore::Location::setHash):
* page/Page.cpp:
(WebCore::Page::userStyleSheetLocationChanged):
* page/UserContentURLPattern.cpp:
(WebCore::UserContentURLPattern::parse):
* page/UserContentURLPattern.h:
(WebCore::UserContentURLPattern::UserContentURLPattern):
* platform/MIMETypeRegistry.cpp:
(WebCore::typesForCommonExtension):
(WebCore::MIMETypeRegistry::mediaMIMETypeForExtension):
* platform/MIMETypeRegistry.h:
* platform/cocoa/DragImageCocoa.mm:
(WebCore::createDragImageIconForCachedImageFilename):
* platform/graphics/MediaPlayer.cpp:
(WebCore::MediaPlayer::load):
* platform/graphics/angle/GraphicsContextGLANGLE.cpp:
(WebCore::GraphicsContextGLANGLE::getUnmangledInfoLog):
* platform/graphics/avfoundation/InbandTextTrackPrivateAVF.cpp:
(WebCore::InbandTextTrackPrivateAVF::processCueAttributes):
* platform/graphics/opengl/GraphicsContextGLOpenGL.cpp:
(WebCore::GraphicsContextGLOpenGL::getUnmangledInfoLog):
* platform/network/HTTPParsers.cpp:
(WebCore::parseStructuredFieldValue):
(WebCore::parseRange):
* platform/network/HTTPParsers.h:
* platform/network/MIMEHeader.cpp:
(WebCore::retrieveKeyValuePairs):
* platform/network/ParsedContentType.cpp:
(WebCore::ParsedContentType::setContentType):
* platform/network/ParsedContentType.h:
* rendering/RenderListMarker.cpp:
(WebCore::RenderListMarker::textRun const):

Source/WebKit:

* Platform/cocoa/ImageAnalysisUtilities.mm:
(WebKit::makeTextRecognitionResult):
* UIProcess/Cocoa/MediaPermissionUtilities.mm:
(WebKit::visibleDomain):
* WebProcess/Plugins/PluginView.cpp:
(WebKit::PluginView::performJavaScriptURLRequest):

Source/WebKitLegacy/mac:

* Misc/WebUserContentURLPattern.mm:
(-[WebUserContentURLPattern initWithPatternString:]):

Modified Paths

Diff

Modified: trunk/Source/_javascript_Core/ChangeLog (292938 => 292939)


--- trunk/Source/_javascript_Core/ChangeLog	2022-04-16 03:41:53 UTC (rev 292938)
+++ trunk/Source/_javascript_Core/ChangeLog	2022-04-16 04:44:41 UTC (rev 292939)
@@ -1,3 +1,26 @@
+2022-04-15  Chris Dumez  <cdu...@apple.com>
+
+        Leverage StringView in more places to avoid some String allocations
+        https://bugs.webkit.org/show_bug.cgi?id=239356
+
+        Reviewed by Darin Adler.
+
+        * inspector/ContentSearchUtilities.cpp:
+        (Inspector::ContentSearchUtilities::getRegularExpressionMatchesByLines):
+        (Inspector::ContentSearchUtilities::findMagicComment):
+        * runtime/ExceptionHelpers.cpp:
+        (JSC::invalidParameterInSourceAppender):
+        (JSC::invalidParameterInstanceofSourceAppender):
+        * runtime/IntlDateTimeFormat.cpp:
+        (JSC::IntlDateTimeFormat::formatToParts const):
+        (JSC::IntlDateTimeFormat::formatRangeToParts):
+        * runtime/IntlListFormat.cpp:
+        (JSC::IntlListFormat::formatToParts const):
+        * runtime/IntlNumberFormat.cpp:
+        (JSC::IntlNumberFormat::formatRangeToPartsInternal):
+        * tools/FunctionOverrides.cpp:
+        (JSC::initializeOverrideInfo):
+
 2022-04-15  Yusuke Suzuki  <ysuz...@apple.com>
 
         [JSC] Remove VM& parameter from structure related code including jsDyamicCast

Modified: trunk/Source/_javascript_Core/inspector/ContentSearchUtilities.cpp (292938 => 292939)


--- trunk/Source/_javascript_Core/inspector/ContentSearchUtilities.cpp	2022-04-16 03:41:53 UTC (rev 292938)
+++ trunk/Source/_javascript_Core/inspector/ContentSearchUtilities.cpp	2022-04-16 04:44:41 UTC (rev 292939)
@@ -87,11 +87,11 @@
 
     for (size_t lineNumber = 0; lineNumber < size; ++lineNumber) {
         size_t nextStart = endings[lineNumber];
-        String line = text.substring(start, nextStart - start);
+        auto line = StringView(text).substring(start, nextStart - start);
 
         int matchLength;
         if (regex.match(line, 0, &matchLength) != -1)
-            result.append(std::pair<size_t, String>(lineNumber, line));
+            result.append({ lineNumber, line.toString() });
 
         start = nextStart;
     }
@@ -175,7 +175,7 @@
     return result;
 }
 
-static String findMagicComment(const String& content, const String& patternString)
+static String findMagicComment(const String& content, ASCIILiteral patternString)
 {
     if (content.isEmpty())
         return String();

Modified: trunk/Source/_javascript_Core/runtime/ExceptionHelpers.cpp (292938 => 292939)


--- trunk/Source/_javascript_Core/runtime/ExceptionHelpers.cpp	2022-04-16 03:41:53 UTC (rev 292938)
+++ trunk/Source/_javascript_Core/runtime/ExceptionHelpers.cpp	2022-04-16 04:44:41 UTC (rev 292939)
@@ -208,7 +208,7 @@
         return makeString(originalMessage, " (evaluating '", sourceText, "')");
 
     static constexpr unsigned inLength = 2;
-    String rightHandSide = sourceText.substring(inIndex + inLength).toStringWithoutCopying().simplifyWhiteSpace();
+    StringView rightHandSide = sourceText.substring(inIndex + inLength).stripLeadingAndTrailingMatchedCharacters(isSpaceOrNewline);
     return makeString(rightHandSide, " is not an Object. (evaluating '", sourceText, "')");
 }
 
@@ -227,7 +227,7 @@
         return makeString(originalMessage, " (evaluating '", sourceText, "')");
 
     static constexpr unsigned instanceofLength = 10;
-    String rightHandSide = sourceText.substring(instanceofIndex + instanceofLength).toStringWithoutCopying().simplifyWhiteSpace();
+    StringView rightHandSide = sourceText.substring(instanceofIndex + instanceofLength).stripLeadingAndTrailingMatchedCharacters(isSpaceOrNewline);
     return makeString(rightHandSide, content, ". (evaluating '", sourceText, "')");
 }
 

Modified: trunk/Source/_javascript_Core/runtime/IntlDateTimeFormat.cpp (292938 => 292939)


--- trunk/Source/_javascript_Core/runtime/IntlDateTimeFormat.cpp	2022-04-16 03:41:53 UTC (rev 292938)
+++ trunk/Source/_javascript_Core/runtime/IntlDateTimeFormat.cpp	2022-04-16 04:44:41 UTC (rev 292939)
@@ -1381,7 +1381,7 @@
     if (!parts)
         return throwOutOfMemoryError(globalObject, scope);
 
-    auto resultString = String(result);
+    StringView resultStringView(result.data(), result.size());
     auto literalString = jsNontrivialString(vm, "literal"_s);
 
     int32_t resultLength = result.size();
@@ -1394,7 +1394,7 @@
             beginIndex = endIndex = resultLength;
 
         if (previousEndIndex < beginIndex) {
-            auto value = jsString(vm, resultString.substring(previousEndIndex, beginIndex - previousEndIndex));
+            auto value = jsString(vm, resultStringView.substring(previousEndIndex, beginIndex - previousEndIndex));
             JSObject* part = constructEmptyObject(globalObject);
             part->putDirect(vm, vm.propertyNames->type, literalString);
             part->putDirect(vm, vm.propertyNames->value, value);
@@ -1407,7 +1407,7 @@
 
         if (fieldType >= 0) {
             auto type = jsNontrivialString(vm, partTypeString(UDateFormatField(fieldType)));
-            auto value = jsString(vm, resultString.substring(beginIndex, endIndex - beginIndex));
+            auto value = jsString(vm, resultStringView.substring(beginIndex, endIndex - beginIndex));
             JSObject* part = constructEmptyObject(globalObject);
             part->putDirect(vm, vm.propertyNames->type, type);
             part->putDirect(vm, vm.propertyNames->value, value);
@@ -1716,7 +1716,7 @@
         throwTypeError(globalObject, scope, "Failed to format date interval"_s);
         return { };
     }
-    String resultString(formattedStringPointer, formattedStringLength);
+    StringView resultStringView(formattedStringPointer, formattedStringLength);
 
     // We care multiple categories (UFIELD_CATEGORY_DATE and UFIELD_CATEGORY_DATE_INTERVAL_SPAN).
     // So we do not constraint iterator.
@@ -1742,7 +1742,7 @@
             return sharedString;
         };
 
-        auto value = jsString(vm, resultString.substring(beginIndex, length));
+        auto value = jsString(vm, resultStringView.substring(beginIndex, length));
         JSObject* part = constructEmptyObject(globalObject);
         part->putDirect(vm, vm.propertyNames->type, type);
         part->putDirect(vm, vm.propertyNames->value, value);
@@ -1750,7 +1750,7 @@
         return part;
     };
 
-    int32_t resultLength = resultString.length();
+    int32_t resultLength = resultStringView.length();
     int32_t previousEndIndex = 0;
     while (true) {
         bool next = ufmtval_nextPosition(formattedValue, iterator.get(), &status);

Modified: trunk/Source/_javascript_Core/runtime/IntlListFormat.cpp (292938 => 292939)


--- trunk/Source/_javascript_Core/runtime/IntlListFormat.cpp	2022-04-16 03:41:53 UTC (rev 292938)
+++ trunk/Source/_javascript_Core/runtime/IntlListFormat.cpp	2022-04-16 04:44:41 UTC (rev 292939)
@@ -268,7 +268,7 @@
     const UChar* formattedStringPointer = ufmtval_getString(formattedValue, &formattedStringLength, &status);
     if (U_FAILURE(status))
         return throwTypeError(globalObject, scope, "failed to format list of strings"_s);
-    String resultString(formattedStringPointer, formattedStringLength);
+    StringView resultStringView(formattedStringPointer, formattedStringLength);
 
     auto iterator = std::unique_ptr<UConstrainedFieldPosition, ICUDeleter<ucfpos_close>>(ucfpos_open(&status));
     if (U_FAILURE(status))
@@ -288,7 +288,7 @@
         return part;
     };
 
-    int32_t resultLength = resultString.length();
+    int32_t resultLength = resultStringView.length();
     int32_t previousEndIndex = 0;
     while (true) {
         bool next = ufmtval_nextPosition(formattedValue, iterator.get(), &status);
@@ -304,7 +304,7 @@
             return throwTypeError(globalObject, scope, "failed to format list of strings"_s);
 
         if (previousEndIndex < beginIndex) {
-            auto value = jsString(vm, resultString.substring(previousEndIndex, beginIndex - previousEndIndex));
+            auto value = jsString(vm, resultStringView.substring(previousEndIndex, beginIndex - previousEndIndex));
             JSObject* part = createPart(literalString, value);
             parts->push(globalObject, part);
             RETURN_IF_EXCEPTION(scope, { });
@@ -311,7 +311,7 @@
         }
         previousEndIndex = endIndex;
 
-        auto value = jsString(vm, resultString.substring(beginIndex, endIndex - beginIndex));
+        auto value = jsString(vm, resultStringView.substring(beginIndex, endIndex - beginIndex));
         JSObject* part = createPart(elementString, value);
         parts->push(globalObject, part);
         RETURN_IF_EXCEPTION(scope, { });
@@ -318,7 +318,7 @@
     }
 
     if (previousEndIndex < resultLength) {
-        auto value = jsString(vm, resultString.substring(previousEndIndex, resultLength - previousEndIndex));
+        auto value = jsString(vm, resultStringView.substring(previousEndIndex, resultLength - previousEndIndex));
         JSObject* part = createPart(literalString, value);
         parts->push(globalObject, part);
         RETURN_IF_EXCEPTION(scope, { });

Modified: trunk/Source/_javascript_Core/runtime/IntlNumberFormat.cpp (292938 => 292939)


--- trunk/Source/_javascript_Core/runtime/IntlNumberFormat.cpp	2022-04-16 03:41:53 UTC (rev 292938)
+++ trunk/Source/_javascript_Core/runtime/IntlNumberFormat.cpp	2022-04-16 04:44:41 UTC (rev 292939)
@@ -1033,7 +1033,7 @@
         throwTypeError(globalObject, scope, "Failed to format number range"_s);
         return;
     }
-    String resultString(formattedStringPointer, formattedStringLength);
+    StringView resultStringView(formattedStringPointer, formattedStringLength);
 
     // We care multiple categories (UFIELD_CATEGORY_DATE and UFIELD_CATEGORY_DATE_INTERVAL_SPAN).
     // So we do not constraint iterator.
@@ -1118,7 +1118,7 @@
             return sharedString;
         };
 
-        auto value = jsString(vm, resultString.substring(beginIndex, length));
+        auto value = jsString(vm, resultStringView.substring(beginIndex, length));
         JSObject* part = constructEmptyObject(globalObject);
         part->putDirect(vm, vm.propertyNames->type, type);
         part->putDirect(vm, vm.propertyNames->value, value);

Modified: trunk/Source/_javascript_Core/tools/FunctionOverrides.cpp (292938 => 292939)


--- trunk/Source/_javascript_Core/tools/FunctionOverrides.cpp	2022-04-16 03:41:53 UTC (rev 292938)
+++ trunk/Source/_javascript_Core/tools/FunctionOverrides.cpp	2022-04-16 04:44:41 UTC (rev 292939)
@@ -133,9 +133,9 @@
     unsigned origFunctionStart = origProviderStr.reverseFind("function", origStart);
     unsigned origBraceStart = origProviderStr.find('{', origStart);
     unsigned headerLength = origBraceStart - origFunctionStart;
-    String origHeader = origProviderStr.substring(origFunctionStart, headerLength);
+    auto origHeaderView = StringView(origProviderStr).substring(origFunctionStart, headerLength);
 
-    String newProviderString = makeString(origHeader, newBody);
+    String newProviderString = makeString(origHeaderView, newBody);
 
     auto overridden = "<overridden>"_s;
     URL url({ }, overridden);

Modified: trunk/Source/WTF/wtf/text/CString.h (292938 => 292939)


--- trunk/Source/WTF/wtf/text/CString.h	2022-04-16 03:41:53 UTC (rev 292938)
+++ trunk/Source/WTF/wtf/text/CString.h	2022-04-16 04:44:41 UTC (rev 292939)
@@ -72,6 +72,8 @@
         return m_buffer ? m_buffer->data() : nullptr;
     }
 
+    std::string toStdString() const { return m_buffer ? std::string(m_buffer->data()) : std::string(); }
+
     const uint8_t* dataAsUInt8Ptr() const { return reinterpret_cast<const uint8_t*>(data()); }
 
     Span<const uint8_t> bytes() const

Modified: trunk/Source/WebCore/ChangeLog (292938 => 292939)


--- trunk/Source/WebCore/ChangeLog	2022-04-16 03:41:53 UTC (rev 292938)
+++ trunk/Source/WebCore/ChangeLog	2022-04-16 04:44:41 UTC (rev 292939)
@@ -1,5 +1,98 @@
 2022-04-15  Chris Dumez  <cdu...@apple.com>
 
+        Leverage StringView in more places to avoid some String allocations
+        https://bugs.webkit.org/show_bug.cgi?id=239356
+
+        Reviewed by Darin Adler.
+
+        * Modules/fetch/FetchBodyConsumer.cpp:
+        (WebCore::FetchBodyConsumer::packageFormData):
+        * Modules/mediastream/libwebrtc/LibWebRTCRtpTransceiverBackend.cpp:
+        (WebCore::toRtpCodecCapability):
+        * Modules/model-element/scenekit/SceneKitModelLoader.mm:
+        (WebCore::mimeTypeUtilizingFileExtensionOverridingForLocalFiles):
+        * Modules/plugins/PluginReplacement.h:
+        (WebCore::ReplacementPlugin::supportsFileExtension const):
+        * Modules/plugins/YouTubePluginReplacement.cpp:
+        (WebCore::YouTubePluginReplacement::supportsFileExtension):
+        * Modules/plugins/YouTubePluginReplacement.h:
+        * animation/KeyframeEffect.cpp:
+        (WebCore::KeyframeEffect::setPseudoElement):
+        * css/ContainerQueryParser.cpp:
+        (WebCore::ContainerQueryParser::consumePlainSizeFeature):
+        * css/parser/CSSSelectorParser.cpp:
+        (WebCore::consumeANPlusB):
+        * dom/SecurityContext.cpp:
+        (WebCore::SecurityContext::parseSandboxPolicy):
+        * dom/SecurityContext.h:
+        * fileapi/ThreadableBlobRegistry.cpp:
+        (WebCore::isBlobURLContainsNullOrigin):
+        * html/DOMTokenList.cpp:
+        (WebCore::DOMTokenList::updateTokensFromAttributeValue):
+        * html/DOMTokenList.h:
+        * html/HTMLMapElement.cpp:
+        (WebCore::HTMLMapElement::parseAttribute):
+        * html/HTMLPlugInElement.cpp:
+        (WebCore::pluginReplacementForType):
+        * html/track/WebVTTParser.cpp:
+        (WebCore::WebVTTParser::checkAndCreateRegion):
+        (WebCore::WebVTTParser::checkAndStoreRegion):
+        (WebCore::WebVTTParser::checkStyleSheet):
+        (WebCore::WebVTTParser::checkAndStoreStyleSheet):
+        * html/track/WebVTTParser.h:
+        * inspector/InspectorStyleSheet.cpp:
+        (WebCore::StyleSheetHandler::observeProperty):
+        (WebCore::StyleSheetHandler::observeComment):
+        * layout/formattingContexts/inline/InlineLineBuilder.cpp:
+        (WebCore::Layout::toString):
+        * layout/formattingContexts/inline/display/InlineDisplayContentBuilder.cpp:
+        (WebCore::Layout::InlineDisplayContentBuilder::appendTextDisplayBox):
+        * layout/layouttree/LayoutInlineTextBox.h:
+        (WebCore::Layout::InlineTextBox::content const):
+        * loader/appcache/ApplicationCacheStorage.cpp:
+        (WebCore::ApplicationCacheStorage::store):
+        (WebCore::ApplicationCacheStorage::writeDataToUniqueFileInDirectory):
+        * loader/appcache/ApplicationCacheStorage.h:
+        * loader/cache/CachedSVGFont.cpp:
+        (WebCore::CachedSVGFont::getSVGFontById const):
+        (WebCore::CachedSVGFont::maybeInitializeExternalSVGFontElement):
+        * loader/cache/CachedSVGFont.h:
+        * page/Location.cpp:
+        (WebCore::Location::setHash):
+        * page/Page.cpp:
+        (WebCore::Page::userStyleSheetLocationChanged):
+        * page/UserContentURLPattern.cpp:
+        (WebCore::UserContentURLPattern::parse):
+        * page/UserContentURLPattern.h:
+        (WebCore::UserContentURLPattern::UserContentURLPattern):
+        * platform/MIMETypeRegistry.cpp:
+        (WebCore::typesForCommonExtension):
+        (WebCore::MIMETypeRegistry::mediaMIMETypeForExtension):
+        * platform/MIMETypeRegistry.h:
+        * platform/cocoa/DragImageCocoa.mm:
+        (WebCore::createDragImageIconForCachedImageFilename):
+        * platform/graphics/MediaPlayer.cpp:
+        (WebCore::MediaPlayer::load):
+        * platform/graphics/angle/GraphicsContextGLANGLE.cpp:
+        (WebCore::GraphicsContextGLANGLE::getUnmangledInfoLog):
+        * platform/graphics/avfoundation/InbandTextTrackPrivateAVF.cpp:
+        (WebCore::InbandTextTrackPrivateAVF::processCueAttributes):
+        * platform/graphics/opengl/GraphicsContextGLOpenGL.cpp:
+        (WebCore::GraphicsContextGLOpenGL::getUnmangledInfoLog):
+        * platform/network/HTTPParsers.cpp:
+        (WebCore::parseStructuredFieldValue):
+        (WebCore::parseRange):
+        * platform/network/HTTPParsers.h:
+        * platform/network/MIMEHeader.cpp:
+        (WebCore::retrieveKeyValuePairs):
+        * platform/network/ParsedContentType.cpp:
+        (WebCore::ParsedContentType::setContentType):
+        * platform/network/ParsedContentType.h:
+        * rendering/RenderListMarker.cpp:
+        (WebCore::RenderListMarker::textRun const):
+
+2022-04-15  Chris Dumez  <cdu...@apple.com>
+
         Rename WebCore::webCoreBuiltinNames() to WebCore::builtinNames()
         https://bugs.webkit.org/show_bug.cgi?id=239408
 

Modified: trunk/Source/WebCore/Modules/fetch/FetchBodyConsumer.cpp (292938 => 292939)


--- trunk/Source/WebCore/Modules/fetch/FetchBodyConsumer.cpp	2022-04-16 03:41:53 UTC (rev 292938)
+++ trunk/Source/WebCore/Modules/fetch/FetchBodyConsumer.cpp	2022-04-16 04:44:41 UTC (rev 292939)
@@ -164,7 +164,7 @@
             size_t contentTypeBegin = header.find(contentTypeCharacters);
             if (contentTypeBegin != notFound) {
                 size_t contentTypeEnd = header.find("\r\n", contentTypeBegin);
-                contentType = stripLeadingAndTrailingHTTPSpaces(header.substring(contentTypeBegin + contentTypePrefixLength, contentTypeEnd - contentTypeBegin - contentTypePrefixLength));
+                contentType = StringView(header).substring(contentTypeBegin + contentTypePrefixLength, contentTypeEnd - contentTypeBegin - contentTypePrefixLength).stripLeadingAndTrailingMatchedCharacters(isHTTPSpace).toString();
             }
 
             form.append(name, File::create(context, Blob::create(context, Vector { bodyBegin, bodyLength }, Blob::normalizedContentType(contentType)).get(), filename).get(), filename);

Modified: trunk/Source/WebCore/Modules/mediastream/libwebrtc/LibWebRTCRtpTransceiverBackend.cpp (292938 => 292939)


--- trunk/Source/WebCore/Modules/mediastream/libwebrtc/LibWebRTCRtpTransceiverBackend.cpp	2022-04-16 03:41:53 UTC (rev 292938)
+++ trunk/Source/WebCore/Modules/mediastream/libwebrtc/LibWebRTCRtpTransceiverBackend.cpp	2022-04-16 04:44:41 UTC (rev 292939)
@@ -91,7 +91,7 @@
     else
         return Exception { InvalidModificationError, "RTCRtpCodecCapability bad mimeType"_s };
 
-    rtcCodec.name = codec.mimeType.substring(6).utf8().data();
+    rtcCodec.name = StringView(codec.mimeType).substring(6).utf8().toStdString();
     rtcCodec.clock_rate = codec.clockRate;
     if (codec.channels)
         rtcCodec.num_channels = *codec.channels;

Modified: trunk/Source/WebCore/Modules/model-element/scenekit/SceneKitModelLoader.mm (292938 => 292939)


--- trunk/Source/WebCore/Modules/model-element/scenekit/SceneKitModelLoader.mm	2022-04-16 03:41:53 UTC (rev 292938)
+++ trunk/Source/WebCore/Modules/model-element/scenekit/SceneKitModelLoader.mm	2022-04-16 04:44:41 UTC (rev 292939)
@@ -79,7 +79,7 @@
         if (position != WTF::notFound) {
             auto extension = lastPathComponent.substring(position + 1);
 
-            return MIMETypeRegistry::mediaMIMETypeForExtension(extension.toString());
+            return MIMETypeRegistry::mediaMIMETypeForExtension(extension);
         }
     }
 

Modified: trunk/Source/WebCore/Modules/plugins/PluginReplacement.h (292938 => 292939)


--- trunk/Source/WebCore/Modules/plugins/PluginReplacement.h	2022-04-16 03:41:53 UTC (rev 292938)
+++ trunk/Source/WebCore/Modules/plugins/PluginReplacement.h	2022-04-16 04:44:41 UTC (rev 292939)
@@ -55,7 +55,7 @@
 
 typedef Ref<PluginReplacement> (*CreatePluginReplacement)(HTMLPlugInElement&, const Vector<String>& paramNames, const Vector<String>& paramValues);
 typedef bool (*PluginReplacementSupportsType)(const String&);
-typedef bool (*PluginReplacementSupportsFileExtension)(const String&);
+typedef bool (*PluginReplacementSupportsFileExtension)(StringView);
 typedef bool (*PluginReplacementSupportsURL)(const URL&);
 typedef bool (*PluginReplacementEnabledForSettings)(const Settings&);
 
@@ -81,7 +81,7 @@
 
     Ref<PluginReplacement> create(HTMLPlugInElement& element, const Vector<String>& paramNames, const Vector<String>& paramValues) const { return m_constructor(element, paramNames, paramValues); }
     bool supportsType(const String& mimeType) const { return m_supportsType(mimeType); }
-    bool supportsFileExtension(const String& extension) const { return m_supportsFileExtension(extension); }
+    bool supportsFileExtension(StringView extension) const { return m_supportsFileExtension(extension); }
     bool supportsURL(const URL& url) const { return m_supportsURL(url); }
     bool isEnabledBySettings(const Settings& settings) const { return m_isEnabledBySettings(settings); };
 

Modified: trunk/Source/WebCore/Modules/plugins/YouTubePluginReplacement.cpp (292938 => 292939)


--- trunk/Source/WebCore/Modules/plugins/YouTubePluginReplacement.cpp	2022-04-16 03:41:53 UTC (rev 292938)
+++ trunk/Source/WebCore/Modules/plugins/YouTubePluginReplacement.cpp	2022-04-16 04:44:41 UTC (rev 292939)
@@ -54,7 +54,7 @@
         || equalLettersIgnoringASCIICase(mimeType, "application/futuresplash");
 }
 
-bool YouTubePluginReplacement::supportsFileExtension(const String& extension)
+bool YouTubePluginReplacement::supportsFileExtension(StringView extension)
 {
     return equalLettersIgnoringASCIICase(extension, "spl") || equalLettersIgnoringASCIICase(extension, "swf");
 }

Modified: trunk/Source/WebCore/Modules/plugins/YouTubePluginReplacement.h (292938 => 292939)


--- trunk/Source/WebCore/Modules/plugins/YouTubePluginReplacement.h	2022-04-16 03:41:53 UTC (rev 292938)
+++ trunk/Source/WebCore/Modules/plugins/YouTubePluginReplacement.h	2022-04-16 04:44:41 UTC (rev 292939)
@@ -45,7 +45,7 @@
     YouTubePluginReplacement(HTMLPlugInElement&, const Vector<String>& paramNames, const Vector<String>& paramValues);
     static Ref<PluginReplacement> create(HTMLPlugInElement&, const Vector<String>& paramNames, const Vector<String>& paramValues);
     static bool supportsMIMEType(const String&);
-    static bool supportsFileExtension(const String&);
+    static bool supportsFileExtension(StringView);
     static bool supportsURL(const URL&);
     static bool isEnabledBySettings(const Settings&);
 

Modified: trunk/Source/WebCore/animation/KeyframeEffect.cpp (292938 => 292939)


--- trunk/Source/WebCore/animation/KeyframeEffect.cpp	2022-04-16 03:41:53 UTC (rev 292938)
+++ trunk/Source/WebCore/animation/KeyframeEffect.cpp	2022-04-16 04:44:41 UTC (rev 292939)
@@ -1185,7 +1185,7 @@
         auto isLegacy = pseudoElement == ":before" || pseudoElement == ":after" || pseudoElement == ":first-letter" || pseudoElement == ":first-line";
         if (!isLegacy && !pseudoElement.startsWith("::"))
             return Exception { SyntaxError };
-        auto pseudoType = CSSSelector::parsePseudoElementType(pseudoElement.substring(isLegacy ? 1 : 2));
+        auto pseudoType = CSSSelector::parsePseudoElementType(StringView(pseudoElement).substring(isLegacy ? 1 : 2));
         if (pseudoType == CSSSelector::PseudoElementUnknown || pseudoType == CSSSelector::PseudoElementWebKitCustom)
             return Exception { SyntaxError };
         pseudoId = CSSSelector::pseudoId(pseudoType);

Modified: trunk/Source/WebCore/css/ContainerQueryParser.cpp (292938 => 292939)


--- trunk/Source/WebCore/css/ContainerQueryParser.cpp	2022-04-16 03:41:53 UTC (rev 292938)
+++ trunk/Source/WebCore/css/ContainerQueryParser.cpp	2022-04-16 04:44:41 UTC (rev 292939)
@@ -181,9 +181,9 @@
         if (name.isEmpty())
             return { };
         if (name.startsWith("min-"))
-            return { name.substring(4), CQ::ComparisonOperator::GreaterThanOrEqual };
+            return { StringView(name).substring(4).toAtomString(), CQ::ComparisonOperator::GreaterThanOrEqual };
         if (name.startsWith("max-"))
-            return { name.substring(4), CQ::ComparisonOperator::LessThanOrEqual };
+            return { StringView(name).substring(4).toAtomString(), CQ::ComparisonOperator::LessThanOrEqual };
 
         return { name, CQ::ComparisonOperator::Equal };
     };

Modified: trunk/Source/WebCore/css/parser/CSSSelectorParser.cpp (292938 => 292939)


--- trunk/Source/WebCore/css/parser/CSSSelectorParser.cpp	2022-04-16 03:41:53 UTC (rev 292938)
+++ trunk/Source/WebCore/css/parser/CSSSelectorParser.cpp	2022-04-16 04:44:41 UTC (rev 292939)
@@ -932,21 +932,21 @@
 
     // The 'n' will end up as part of an ident or dimension. For a valid <an+b>,
     // this will store a string of the form 'n', 'n-', or 'n-123'.
-    String nString;
+    StringView nString;
 
     if (token.type() == DelimiterToken && token.delimiter() == '+' && range.peek().type() == IdentToken) {
         result.first = 1;
-        nString = range.consume().value().toString();
+        nString = range.consume().value();
     } else if (token.type() == DimensionToken && token.numericValueType() == IntegerValueType) {
         result.first = token.numericValue();
-        nString = token.unitString().toString();
+        nString = token.unitString();
     } else if (token.type() == IdentToken) {
         if (token.value()[0] == '-') {
             result.first = -1;
-            nString = token.value().substring(1).toString();
+            nString = token.value().substring(1);
         } else {
             result.first = 1;
-            nString = token.value().toString();
+            nString = token.value();
         }
     }
 
@@ -958,7 +958,7 @@
         return false;
 
     if (nString.length() > 2) {
-        auto parsedNumber = parseInteger<int>(StringView { nString }.substring(1));
+        auto parsedNumber = parseInteger<int>(nString.substring(1));
         result.second = parsedNumber.value_or(0);
         return parsedNumber.has_value();
     }

Modified: trunk/Source/WebCore/dom/SecurityContext.cpp (292938 => 292939)


--- trunk/Source/WebCore/dom/SecurityContext.cpp	2022-04-16 03:41:53 UTC (rev 292938)
+++ trunk/Source/WebCore/dom/SecurityContext.cpp	2022-04-16 04:44:41 UTC (rev 292939)
@@ -95,7 +95,7 @@
 }
 
 // Keep SecurityContext::isSupportedSandboxPolicy() in sync when updating this function.
-SandboxFlags SecurityContext::parseSandboxPolicy(const String& policy, String& invalidTokensErrorMessage)
+SandboxFlags SecurityContext::parseSandboxPolicy(StringView policy, String& invalidTokensErrorMessage)
 {
     // http://www.w3.org/TR/html5/the-iframe-element.html#attr-iframe-sandbox
     // Parse the unordered set of unique space-separated tokens.
@@ -114,7 +114,7 @@
             ++end;
 
         // Turn off the corresponding sandbox flag if it's set as "allowed".
-        String sandboxToken = policy.substring(start, end - start);
+        auto sandboxToken = policy.substring(start, end - start);
         if (equalLettersIgnoringASCIICase(sandboxToken, "allow-same-origin"))
             flags &= ~SandboxOrigin;
         else if (equalLettersIgnoringASCIICase(sandboxToken, "allow-forms"))

Modified: trunk/Source/WebCore/dom/SecurityContext.h (292938 => 292939)


--- trunk/Source/WebCore/dom/SecurityContext.h	2022-04-16 03:41:53 UTC (rev 292938)
+++ trunk/Source/WebCore/dom/SecurityContext.h	2022-04-16 04:44:41 UTC (rev 292939)
@@ -100,7 +100,7 @@
 
     WEBCORE_EXPORT SecurityOrigin* securityOrigin() const;
 
-    static SandboxFlags parseSandboxPolicy(const String& policy, String& invalidTokensErrorMessage);
+    static SandboxFlags parseSandboxPolicy(StringView policy, String& invalidTokensErrorMessage);
     static bool isSupportedSandboxPolicy(StringView);
 
     enum MixedContentType {

Modified: trunk/Source/WebCore/fileapi/ThreadableBlobRegistry.cpp (292938 => 292939)


--- trunk/Source/WebCore/fileapi/ThreadableBlobRegistry.cpp	2022-04-16 03:41:53 UTC (rev 292938)
+++ trunk/Source/WebCore/fileapi/ThreadableBlobRegistry.cpp	2022-04-16 04:44:41 UTC (rev 292939)
@@ -96,7 +96,7 @@
     ASSERT(url.protocolIsBlob());
     unsigned startIndex = url.pathStart();
     unsigned endIndex = url.pathAfterLastSlash();
-    return url.string().substring(startIndex, endIndex - startIndex - 1) == "null";
+    return StringView(url.string()).substring(startIndex, endIndex - startIndex - 1) == "null";
 }
 
 void ThreadableBlobRegistry::registerBlobURL(SecurityOrigin* origin, PolicyContainer&& policyContainer, const URL& url, const URL& srcURL)

Modified: trunk/Source/WebCore/html/DOMTokenList.cpp (292938 => 292939)


--- trunk/Source/WebCore/html/DOMTokenList.cpp	2022-04-16 03:41:53 UTC (rev 292938)
+++ trunk/Source/WebCore/html/DOMTokenList.cpp	2022-04-16 04:44:41 UTC (rev 292939)
@@ -220,7 +220,7 @@
     m_element.setAttribute(m_attributeName, value);
 }
 
-void DOMTokenList::updateTokensFromAttributeValue(const String& value)
+void DOMTokenList::updateTokensFromAttributeValue(StringView value)
 {
     // Clear tokens but not capacity.
     m_tokens.shrink(0);
@@ -236,10 +236,11 @@
         while (end < value.length() && !isHTMLSpace(value[end]))
             ++end;
 
-        AtomString token = value.substring(start, end - start);
-        if (!addedTokens.contains(token)) {
+        auto tokenView = value.substring(start, end - start);
+        if (!addedTokens.contains<StringViewHashTranslator>(tokenView)) {
+            auto token = tokenView.toAtomString();
             m_tokens.append(token);
-            addedTokens.add(token);
+            addedTokens.add(WTFMove(token));
         }
 
         start = end + 1;

Modified: trunk/Source/WebCore/html/DOMTokenList.h (292938 => 292939)


--- trunk/Source/WebCore/html/DOMTokenList.h	2022-04-16 03:41:53 UTC (rev 292938)
+++ trunk/Source/WebCore/html/DOMTokenList.h	2022-04-16 04:44:41 UTC (rev 292939)
@@ -59,7 +59,7 @@
     WEBCORE_EXPORT const AtomString& value() const;
 
 private:
-    void updateTokensFromAttributeValue(const String&);
+    void updateTokensFromAttributeValue(StringView);
     void updateAssociatedAttributeFromTokens();
 
     WEBCORE_EXPORT Vector<AtomString>& tokens();

Modified: trunk/Source/WebCore/html/HTMLMapElement.cpp (292938 => 292939)


--- trunk/Source/WebCore/html/HTMLMapElement.cpp	2022-04-16 03:41:53 UTC (rev 292938)
+++ trunk/Source/WebCore/html/HTMLMapElement.cpp	2022-04-16 04:44:41 UTC (rev 292939)
@@ -99,8 +99,8 @@
             treeScope().removeImageMap(*this);
         String mapName = value;
         if (mapName[0] == '#')
-            mapName = mapName.substring(1);
-        m_name = mapName;
+            mapName = StringView(mapName).substring(1).toAtomString();
+        m_name = WTFMove(mapName);
         if (isConnected())
             treeScope().addImageMap(*this);
 

Modified: trunk/Source/WebCore/html/HTMLPlugInElement.cpp (292938 => 292939)


--- trunk/Source/WebCore/html/HTMLPlugInElement.cpp	2022-04-16 03:41:53 UTC (rev 292938)
+++ trunk/Source/WebCore/html/HTMLPlugInElement.cpp	2022-04-16 04:44:41 UTC (rev 292939)
@@ -308,11 +308,11 @@
     if (replacements.isEmpty())
         return nullptr;
 
-    String extension;
+    StringView extension;
     auto lastPathComponent = url.lastPathComponent();
     size_t dotOffset = lastPathComponent.reverseFind('.');
     if (dotOffset != notFound)
-        extension = lastPathComponent.substring(dotOffset + 1).toString();
+        extension = lastPathComponent.substring(dotOffset + 1);
 
     String type = mimeType;
     if (type.isEmpty() && url.protocolIsData())

Modified: trunk/Source/WebCore/html/track/WebVTTParser.cpp (292938 => 292939)


--- trunk/Source/WebCore/html/track/WebVTTParser.cpp	2022-04-16 03:41:53 UTC (rev 292938)
+++ trunk/Source/WebCore/html/track/WebVTTParser.cpp	2022-04-16 04:44:41 UTC (rev 292939)
@@ -315,7 +315,7 @@
     return Style;
 }
 
-bool WebVTTParser::checkAndCreateRegion(const String& line)
+bool WebVTTParser::checkAndCreateRegion(StringView line)
 {
     if (m_previousLine.contains("-->"))
         return false;
@@ -329,7 +329,7 @@
     return false;
 }
 
-bool WebVTTParser::checkAndStoreRegion(const String& line)
+bool WebVTTParser::checkAndStoreRegion(StringView line)
 {
     if (!line.isEmpty() && !line.contains("-->"))
         return false;
@@ -344,7 +344,7 @@
     return true;
 }
 
-bool WebVTTParser::checkStyleSheet(const String& line)
+bool WebVTTParser::checkStyleSheet(StringView line)
 {
     if (m_previousLine.contains("-->"))
         return false;
@@ -357,7 +357,7 @@
     return false;
 }
 
-bool WebVTTParser::checkAndStoreStyleSheet(const String& line)
+bool WebVTTParser::checkAndStoreStyleSheet(StringView line)
 {
     if (!line.isEmpty() && !line.contains("-->"))
         return false;

Modified: trunk/Source/WebCore/html/track/WebVTTParser.h (292938 => 292939)


--- trunk/Source/WebCore/html/track/WebVTTParser.h	2022-04-16 03:41:53 UTC (rev 292938)
+++ trunk/Source/WebCore/html/track/WebVTTParser.h	2022-04-16 04:44:41 UTC (rev 292939)
@@ -170,10 +170,10 @@
     ParseState collectWebVTTBlock(const String&);
     ParseState checkAndRecoverCue(const String& line);
     ParseState collectStyleSheet(const String&);
-    bool checkAndCreateRegion(const String& line);
-    bool checkAndStoreRegion(const String& line);
-    bool checkStyleSheet(const String& line);
-    bool checkAndStoreStyleSheet(const String& line);
+    bool checkAndCreateRegion(StringView line);
+    bool checkAndStoreRegion(StringView line);
+    bool checkStyleSheet(StringView line);
+    bool checkAndStoreStyleSheet(StringView line);
 
     void createNewCue();
     void resetCueValues();

Modified: trunk/Source/WebCore/inspector/InspectorStyleSheet.cpp (292938 => 292939)


--- trunk/Source/WebCore/inspector/InspectorStyleSheet.cpp	2022-04-16 03:41:53 UTC (rev 292938)
+++ trunk/Source/WebCore/inspector/InspectorStyleSheet.cpp	2022-04-16 04:44:41 UTC (rev 292939)
@@ -352,14 +352,14 @@
         ++endOffset;
     
     ASSERT(startOffset < endOffset);
-    String propertyString = m_parsedText.substring(startOffset, endOffset - startOffset).stripWhiteSpace();
+    StringView propertyString = StringView(m_parsedText).substring(startOffset, endOffset - startOffset).stripLeadingAndTrailingMatchedCharacters(isSpaceOrNewline);
     if (propertyString.endsWith(';'))
         propertyString = propertyString.left(propertyString.length() - 1);
     size_t colonIndex = propertyString.find(':');
     ASSERT(colonIndex != notFound);
 
-    String name = propertyString.left(colonIndex).stripWhiteSpace();
-    String value = propertyString.substring(colonIndex + 1, propertyString.length()).stripWhiteSpace();
+    String name = propertyString.left(colonIndex).stripLeadingAndTrailingMatchedCharacters(isSpaceOrNewline).toString();
+    String value = propertyString.substring(colonIndex + 1, propertyString.length()).stripLeadingAndTrailingMatchedCharacters(isSpaceOrNewline).toString();
     
     // FIXME-NEWPARSER: The property range is relative to the declaration start offset, but no
     // good reason for it, and it complicates fixUnparsedProperties.
@@ -376,17 +376,19 @@
     
     // The lexer is not inside a property AND it is scanning a declaration-aware
     // rule body.
-    String commentText = m_parsedText.substring(startOffset, endOffset - startOffset);
+    auto commentTextView = StringView(m_parsedText).substring(startOffset, endOffset - startOffset);
     
-    ASSERT(commentText.startsWith("/*"));
-    commentText = commentText.substring(2);
+    ASSERT(commentTextView.startsWith("/*"));
+    commentTextView = commentTextView.substring(2);
     
     // Require well-formed comments.
-    if (!commentText.endsWith("*/"))
+    if (!commentTextView.endsWith("*/"))
         return;
-    commentText = commentText.left(commentText.length() - 2).stripWhiteSpace();
-    if (commentText.isEmpty())
+    commentTextView = commentTextView.left(commentTextView.length() - 2).stripLeadingAndTrailingMatchedCharacters(isSpaceOrNewline);
+    if (commentTextView.isEmpty())
         return;
+
+    auto commentText = commentTextView.toString();
     
     // FIXME: Use the actual rule type rather than STYLE_RULE?
     RuleSourceDataList sourceData;

Modified: trunk/Source/WebCore/layout/formattingContexts/inline/InlineLineBuilder.cpp (292938 => 292939)


--- trunk/Source/WebCore/layout/formattingContexts/inline/InlineLineBuilder.cpp	2022-04-16 03:41:53 UTC (rev 292938)
+++ trunk/Source/WebCore/layout/formattingContexts/inline/InlineLineBuilder.cpp	2022-04-16 04:44:41 UTC (rev 292939)
@@ -49,7 +49,7 @@
         if (!run.isText())
             continue;
         auto& textContent = run.textContent();
-        lineContentBuilder.append(downcast<InlineTextBox>(run.layoutBox()).content().substring(textContent->start, textContent->length));
+        lineContentBuilder.append(StringView(downcast<InlineTextBox>(run.layoutBox()).content()).substring(textContent->start, textContent->length));
     }
     return lineContentBuilder;
 }

Modified: trunk/Source/WebCore/layout/formattingContexts/inline/display/InlineDisplayContentBuilder.cpp (292938 => 292939)


--- trunk/Source/WebCore/layout/formattingContexts/inline/display/InlineDisplayContentBuilder.cpp	2022-04-16 03:41:53 UTC (rev 292938)
+++ trunk/Source/WebCore/layout/formattingContexts/inline/display/InlineDisplayContentBuilder.cpp	2022-04-16 04:44:41 UTC (rev 292939)
@@ -163,10 +163,10 @@
 
         return inkOverflow;
     };
-    auto content = downcast<InlineTextBox>(layoutBox).content();
-    auto text = lineRun.textContent();
+    auto& content = downcast<InlineTextBox>(layoutBox).content();
+    auto& text = lineRun.textContent();
     auto adjustedContentToRender = [&] {
-        return text->needsHyphen ? makeString(content.substring(text->start, text->length), style.hyphenString()) : String();
+        return text->needsHyphen ? makeString(StringView(content).substring(text->start, text->length), style.hyphenString()) : String();
     };
     boxes.append({ m_lineIndex
         , lineRun.isWordSeparator() ? InlineDisplay::Box::Type::WordSeparator : InlineDisplay::Box::Type::Text

Modified: trunk/Source/WebCore/layout/layouttree/LayoutInlineTextBox.h (292938 => 292939)


--- trunk/Source/WebCore/layout/layouttree/LayoutInlineTextBox.h	2022-04-16 03:41:53 UTC (rev 292938)
+++ trunk/Source/WebCore/layout/layouttree/LayoutInlineTextBox.h	2022-04-16 04:44:41 UTC (rev 292939)
@@ -40,7 +40,7 @@
     InlineTextBox(String, bool canUseSimplifiedContentMeasuring, bool canUseSimpleFontCodePath, RenderStyle&&, std::unique_ptr<RenderStyle>&& firstLineStyle = nullptr);
     virtual ~InlineTextBox() = default;
 
-    String content() const { return m_content; }
+    const String& content() const { return m_content; }
     // FIXME: This should not be a box's property.
     bool canUseSimplifiedContentMeasuring() const { return m_canUseSimplifiedContentMeasuring; }
     bool canUseSimpleFontCodePath() const { return m_canUseSimpleFontCodePath; }

Modified: trunk/Source/WebCore/loader/appcache/ApplicationCacheStorage.cpp (292938 => 292939)


--- trunk/Source/WebCore/loader/appcache/ApplicationCacheStorage.cpp	2022-04-16 03:41:53 UTC (rev 292938)
+++ trunk/Source/WebCore/loader/appcache/ApplicationCacheStorage.cpp	2022-04-16 04:44:41 UTC (rev 292939)
@@ -798,12 +798,12 @@
         String flatFileDirectory = FileSystem::pathByAppendingComponent(m_cacheDirectory, m_flatFileSubdirectoryName);
         FileSystem::makeAllDirectories(flatFileDirectory);
 
-        String extension;
+        StringView extension;
         
         String fileName = resource->response().suggestedFilename();
         size_t dotIndex = fileName.reverseFind('.');
         if (dotIndex != notFound && dotIndex < (fileName.length() - 1))
-            extension = fileName.substring(dotIndex);
+            extension = StringView(fileName).substring(dotIndex);
 
         String path;
         if (!writeDataToUniqueFileInDirectory(resource->data(), flatFileDirectory, path, extension))
@@ -1272,12 +1272,12 @@
     return startsWithLettersIgnoringASCIICase(type, "audio/") || startsWithLettersIgnoringASCIICase(type, "video/");
 }
     
-bool ApplicationCacheStorage::writeDataToUniqueFileInDirectory(FragmentedSharedBuffer& data, const String& directory, String& path, const String& fileExtension)
+bool ApplicationCacheStorage::writeDataToUniqueFileInDirectory(FragmentedSharedBuffer& data, const String& directory, String& path, StringView fileExtension)
 {
     String fullPath;
     
     do {
-        path = FileSystem::encodeForFileName(createVersion4UUIDString()) + fileExtension;
+        path = makeString(FileSystem::encodeForFileName(createVersion4UUIDString()), fileExtension);
         // Guard against the above function being called on a platform which does not implement
         // createVersion4UUIDString().
         ASSERT(!path.isEmpty());

Modified: trunk/Source/WebCore/loader/appcache/ApplicationCacheStorage.h (292938 => 292939)


--- trunk/Source/WebCore/loader/appcache/ApplicationCacheStorage.h	2022-04-16 03:41:53 UTC (rev 292938)
+++ trunk/Source/WebCore/loader/appcache/ApplicationCacheStorage.h	2022-04-16 04:44:41 UTC (rev 292939)
@@ -122,7 +122,7 @@
     bool ensureOriginRecord(const SecurityOrigin*);
     static bool shouldStoreResourceAsFlatFile(ApplicationCacheResource*);
     void deleteTables();
-    bool writeDataToUniqueFileInDirectory(FragmentedSharedBuffer&, const String& directory, String& outFilename, const String& fileExtension);
+    bool writeDataToUniqueFileInDirectory(FragmentedSharedBuffer&, const String& directory, String& outFilename, StringView fileExtension);
 
     void loadManifestHostHashes();
     

Modified: trunk/Source/WebCore/loader/cache/CachedSVGFont.cpp (292938 => 292939)


--- trunk/Source/WebCore/loader/cache/CachedSVGFont.cpp	2022-04-16 03:41:53 UTC (rev 292938)
+++ trunk/Source/WebCore/loader/cache/CachedSVGFont.cpp	2022-04-16 04:44:41 UTC (rev 292939)
@@ -103,7 +103,7 @@
     return m_externalSVGDocument && CachedFont::ensureCustomFontData(m_convertedFont.get());
 }
 
-SVGFontElement* CachedSVGFont::getSVGFontById(const String& fontName) const
+SVGFontElement* CachedSVGFont::getSVGFontById(const AtomString& fontName) const
 {
     ASSERT(m_externalSVGDocument);
     auto elements = descendantsOfType<SVGFontElement>(*m_externalSVGDocument);
@@ -122,10 +122,10 @@
 {
     if (m_externalSVGFontElement)
         return m_externalSVGFontElement;
-    String fragmentIdentifier;
+    AtomString fragmentIdentifier;
     size_t start = remoteURI.find('#');
     if (start != notFound)
-        fragmentIdentifier = remoteURI.string().substring(start + 1);
+        fragmentIdentifier = StringView(remoteURI).substring(start + 1).toAtomString();
     m_externalSVGFontElement = getSVGFontById(fragmentIdentifier);
     return m_externalSVGFontElement;
 }

Modified: trunk/Source/WebCore/loader/cache/CachedSVGFont.h (292938 => 292939)


--- trunk/Source/WebCore/loader/cache/CachedSVGFont.h	2022-04-16 03:41:53 UTC (rev 292938)
+++ trunk/Source/WebCore/loader/cache/CachedSVGFont.h	2022-04-16 04:44:41 UTC (rev 292939)
@@ -45,7 +45,7 @@
 private:
     FontPlatformData platformDataFromCustomData(const FontDescription&, bool bold, bool italic, const FontCreationContext&);
 
-    SVGFontElement* getSVGFontById(const String&) const;
+    SVGFontElement* getSVGFontById(const AtomString&) const;
 
     SVGFontElement* maybeInitializeExternalSVGFontElement(const AtomString& remoteURI);
     SVGFontFaceElement* firstFontFace(const AtomString& remoteURI);

Modified: trunk/Source/WebCore/page/Location.cpp (292938 => 292939)


--- trunk/Source/WebCore/page/Location.cpp	2022-04-16 03:41:53 UTC (rev 292938)
+++ trunk/Source/WebCore/page/Location.cpp	2022-04-16 04:44:41 UTC (rev 292939)
@@ -198,9 +198,9 @@
     ASSERT(frame->document());
     auto url = ""
     auto oldFragmentIdentifier = url.fragmentIdentifier();
-    auto newFragmentIdentifier = hash;
-    if (hash[0] == '#')
-        newFragmentIdentifier = hash.substring(1);
+    StringView newFragmentIdentifier { hash };
+    if (hash.startsWith('#'))
+        newFragmentIdentifier = newFragmentIdentifier.substring(1);
     url.setFragmentIdentifier(newFragmentIdentifier);
     // Note that by parsing the URL and *then* comparing fragments, we are 
     // comparing fragments post-canonicalization, and so this handles the 

Modified: trunk/Source/WebCore/page/Page.cpp (292938 => 292939)


--- trunk/Source/WebCore/page/Page.cpp	2022-04-16 03:41:53 UTC (rev 292938)
+++ trunk/Source/WebCore/page/Page.cpp	2022-04-16 04:44:41 UTC (rev 292939)
@@ -2023,7 +2023,7 @@
     if (url.protocolIsData() && url.string().startsWith("data:text/css;charset=utf-8;base64,")) {
         m_didLoadUserStyleSheet = true;
 
-        if (auto styleSheetAsUTF8 = base64Decode(PAL::decodeURLEscapeSequences(url.string().substring(35)), Base64DecodeOptions::IgnoreSpacesAndNewLines))
+        if (auto styleSheetAsUTF8 = base64Decode(PAL::decodeURLEscapeSequences(StringView(url.string()).substring(35)), Base64DecodeOptions::IgnoreSpacesAndNewLines))
             m_userStyleSheet = String::fromUTF8(styleSheetAsUTF8->data(), styleSheetAsUTF8->size());
     }
 

Modified: trunk/Source/WebCore/page/UserContentURLPattern.cpp (292938 => 292939)


--- trunk/Source/WebCore/page/UserContentURLPattern.cpp	2022-04-16 03:41:53 UTC (rev 292938)
+++ trunk/Source/WebCore/page/UserContentURLPattern.cpp	2022-04-16 04:44:41 UTC (rev 292939)
@@ -61,15 +61,15 @@
     return matchesAllowlist && !matchesBlocklist;
 }
 
-bool UserContentURLPattern::parse(const String& pattern)
+bool UserContentURLPattern::parse(StringView pattern)
 {
     static constexpr ASCIILiteral schemeSeparator = "://"_s;
 
-    size_t schemeEndPos = pattern.find(StringView { schemeSeparator });
+    size_t schemeEndPos = pattern.find(schemeSeparator);
     if (schemeEndPos == notFound)
         return false;
 
-    m_scheme = pattern.left(schemeEndPos);
+    m_scheme = pattern.left(schemeEndPos).toString();
 
     unsigned hostStartPos = schemeEndPos + schemeSeparator.length();
     if (hostStartPos >= pattern.length())
@@ -84,7 +84,7 @@
         if (hostEndPos == notFound)
             return false;
 
-        m_host = pattern.substring(hostStartPos, hostEndPos - hostStartPos);
+        m_host = pattern.substring(hostStartPos, hostEndPos - hostStartPos).toString();
         m_matchSubdomains = false;
 
         if (m_host == "*") {
@@ -104,7 +104,7 @@
         pathStartPos = hostEndPos;
     }
 
-    m_path = pattern.right(pattern.length() - pathStartPos);
+    m_path = pattern.right(pattern.length() - pathStartPos).toString();
 
     return true;
 }

Modified: trunk/Source/WebCore/page/UserContentURLPattern.h (292938 => 292939)


--- trunk/Source/WebCore/page/UserContentURLPattern.h	2022-04-16 03:41:53 UTC (rev 292938)
+++ trunk/Source/WebCore/page/UserContentURLPattern.h	2022-04-16 04:44:41 UTC (rev 292939)
@@ -32,10 +32,9 @@
 
 class UserContentURLPattern {
 public:
-    UserContentURLPattern() : m_invalid(true), m_matchSubdomains(false) { }
+    UserContentURLPattern() = default;
 
-    UserContentURLPattern(const String& pattern)
-    : m_matchSubdomains(false)
+    explicit UserContentURLPattern(StringView pattern)
     {
         m_invalid = !parse(pattern);
     }
@@ -53,18 +52,17 @@
     static bool matchesPatterns(const URL&, const Vector<String>& allowlist, const Vector<String>& blocklist);
 
 private:
-    WEBCORE_EXPORT bool parse(const String& pattern);
+    WEBCORE_EXPORT bool parse(StringView pattern);
 
     bool matchesHost(const URL&) const;
     bool matchesPath(const URL&) const;
 
-    bool m_invalid;
-
     String m_scheme;
     String m_host;
     String m_path;
 
-    bool m_matchSubdomains;
+    bool m_invalid { true };
+    bool m_matchSubdomains { false };
 };
 
 } // namespace WebCore

Modified: trunk/Source/WebCore/platform/MIMETypeRegistry.cpp (292938 => 292939)


--- trunk/Source/WebCore/platform/MIMETypeRegistry.cpp	2022-04-16 03:41:53 UTC (rev 292938)
+++ trunk/Source/WebCore/platform/MIMETypeRegistry.cpp	2022-04-16 04:44:41 UTC (rev 292939)
@@ -379,15 +379,15 @@
     return mimeTypesMap;
 }
 
-static const Vector<String>* typesForCommonExtension(const String& extension)
+static const Vector<String>* typesForCommonExtension(StringView extension)
 {
-    auto mapEntry = commonMimeTypesMap().find(extension);
+    auto mapEntry = commonMimeTypesMap().find<ASCIICaseInsensitiveStringViewHashTranslator>(extension);
     if (mapEntry == commonMimeTypesMap().end())
         return nullptr;
     return &mapEntry->value;
 }
 
-String MIMETypeRegistry::mediaMIMETypeForExtension(const String& extension)
+String MIMETypeRegistry::mediaMIMETypeForExtension(StringView extension)
 {
     auto* vector = typesForCommonExtension(extension);
     if (vector)

Modified: trunk/Source/WebCore/platform/MIMETypeRegistry.h (292938 => 292939)


--- trunk/Source/WebCore/platform/MIMETypeRegistry.h	2022-04-16 03:41:53 UTC (rev 292938)
+++ trunk/Source/WebCore/platform/MIMETypeRegistry.h	2022-04-16 04:44:41 UTC (rev 292939)
@@ -56,7 +56,7 @@
     WEBCORE_EXPORT static String mimeTypeForExtension(StringView);
     WEBCORE_EXPORT static Vector<String> extensionsForMIMEType(const String& type);
     WEBCORE_EXPORT static String preferredExtensionForMIMEType(const String& type);
-    WEBCORE_EXPORT static String mediaMIMETypeForExtension(const String& extension);
+    WEBCORE_EXPORT static String mediaMIMETypeForExtension(StringView extension);
 
     WEBCORE_EXPORT static String mimeTypeForPath(StringView);
 

Modified: trunk/Source/WebCore/platform/cocoa/DragImageCocoa.mm (292938 => 292939)


--- trunk/Source/WebCore/platform/cocoa/DragImageCocoa.mm	2022-04-16 03:41:53 UTC (rev 292938)
+++ trunk/Source/WebCore/platform/cocoa/DragImageCocoa.mm	2022-04-16 04:44:41 UTC (rev 292939)
@@ -139,11 +139,11 @@
     
 RetainPtr<NSImage> createDragImageIconForCachedImageFilename(const String& filename)
 {
-    NSString *extension = nil;
+    RetainPtr<NSString> extension;
     size_t dotIndex = filename.reverseFind('.');
     
     if (dotIndex != notFound && dotIndex < (filename.length() - 1)) // require that a . exists after the first character and before the last
-        extension = filename.substring(dotIndex + 1);
+        extension = StringView(filename).substring(dotIndex + 1).createNSString();
     else {
         // It might be worth doing a further lookup to pull the extension from the MIME type.
         extension = @"";
@@ -150,7 +150,7 @@
     }
     
     ALLOW_DEPRECATED_DECLARATIONS_BEGIN
-    return [[NSWorkspace sharedWorkspace] iconForFileType:extension];
+    return [[NSWorkspace sharedWorkspace] iconForFileType:extension.get()];
     ALLOW_DEPRECATED_DECLARATIONS_END
 }
 

Modified: trunk/Source/WebCore/platform/graphics/MediaPlayer.cpp (292938 => 292939)


--- trunk/Source/WebCore/platform/graphics/MediaPlayer.cpp	2022-04-16 03:41:53 UTC (rev 292938)
+++ trunk/Source/WebCore/platform/graphics/MediaPlayer.cpp	2022-04-16 04:44:41 UTC (rev 292939)
@@ -493,7 +493,7 @@
             auto lastPathComponent = url.lastPathComponent();
             size_t pos = lastPathComponent.reverseFind('.');
             if (pos != notFound) {
-                String extension = lastPathComponent.substring(pos + 1).toString();
+                auto extension = lastPathComponent.substring(pos + 1);
                 String mediaType = MIMETypeRegistry::mediaMIMETypeForExtension(extension);
                 if (!mediaType.isEmpty()) {
                     m_contentType = ContentType { WTFMove(mediaType) };

Modified: trunk/Source/WebCore/platform/graphics/angle/GraphicsContextGLANGLE.cpp (292938 => 292939)


--- trunk/Source/WebCore/platform/graphics/angle/GraphicsContextGLANGLE.cpp	2022-04-16 03:41:53 UTC (rev 292938)
+++ trunk/Source/WebCore/platform/graphics/angle/GraphicsContextGLANGLE.cpp	2022-04-16 04:44:41 UTC (rev 292939)
@@ -1903,7 +1903,7 @@
     // is causing it.
     static constexpr char angleWarning[] = "WARNING: 0:1: extension 'GL_ARB_gpu_shader5' is not supported\n";
     int startFrom = log.startsWith(angleWarning) ? strlen(angleWarning) : 0;
-    processedLog.append(log.substring(startFrom, log.length() - startFrom));
+    processedLog.append(StringView(log).substring(startFrom, log.length() - startFrom));
 
     LOG(WebGL, "Unmangled ShaderInfoLog:\n%s", processedLog.toString().utf8().data());
     return processedLog.toString();

Modified: trunk/Source/WebCore/platform/graphics/avfoundation/InbandTextTrackPrivateAVF.cpp (292938 => 292939)


--- trunk/Source/WebCore/platform/graphics/avfoundation/InbandTextTrackPrivateAVF.cpp	2022-04-16 03:41:53 UTC (rev 292938)
+++ trunk/Source/WebCore/platform/graphics/avfoundation/InbandTextTrackPrivateAVF.cpp	2022-04-16 04:44:41 UTC (rev 292939)
@@ -300,7 +300,7 @@
         }
 
         content.append(tagStart);
-        content.append(attributedStringValue.substring(effectiveRange.location, effectiveRange.length));
+        content.append(StringView(attributedStringValue).substring(effectiveRange.location, effectiveRange.length));
         content.append(tagEnd);
     }
 

Modified: trunk/Source/WebCore/platform/graphics/opengl/GraphicsContextGLOpenGL.cpp (292938 => 292939)


--- trunk/Source/WebCore/platform/graphics/opengl/GraphicsContextGLOpenGL.cpp	2022-04-16 03:41:53 UTC (rev 292938)
+++ trunk/Source/WebCore/platform/graphics/opengl/GraphicsContextGLOpenGL.cpp	2022-04-16 04:44:41 UTC (rev 292939)
@@ -1984,7 +1984,7 @@
         if (start == -1)
             break;
 
-        processedLog.append(log.substring(startFrom, start - startFrom));
+        processedLog.append(StringView(log).substring(startFrom, start - startFrom));
         startFrom = start + matchedLength;
 
         const String& mangledSymbol = log.substring(start, matchedLength);
@@ -1993,7 +1993,7 @@
         processedLog.append(mappedSymbol);
     } while (startFrom < static_cast<int>(log.length()));
 
-    processedLog.append(log.substring(startFrom, log.length() - startFrom));
+    processedLog.append(StringView(log).substring(startFrom, log.length() - startFrom));
 
     LOG(WebGL, "Unmangled ShaderInfoLog:\n%s", processedLog.toString().utf8().data());
     return processedLog.toString();

Modified: trunk/Source/WebCore/platform/network/HTTPParsers.cpp (292938 => 292939)


--- trunk/Source/WebCore/platform/network/HTTPParsers.cpp	2022-04-16 03:41:53 UTC (rev 292938)
+++ trunk/Source/WebCore/platform/network/HTTPParsers.cpp	2022-04-16 04:44:41 UTC (rev 292939)
@@ -618,7 +618,7 @@
                 break;
             ++index;
         }
-        String key = header.substring(keyStart, index - keyStart).toString();
+        StringView key = header.substring(keyStart, index - keyStart);
         String value = "true"_s;
         if (index < header.length() && header[index] == '=') {
             ++index; // Consume '='.
@@ -659,7 +659,7 @@
             } else
                 return std::nullopt;
         }
-        parameters.set(WTFMove(key), WTFMove(value));
+        parameters.set(key.toString(), WTFMove(value));
     }
     if (index != header.length())
         return std::nullopt;
@@ -666,7 +666,7 @@
     return std::make_pair(bareItem, parameters);
 }
 
-bool parseRange(const String& range, long long& rangeOffset, long long& rangeEnd, long long& rangeSuffixLength)
+bool parseRange(StringView range, long long& rangeOffset, long long& rangeEnd, long long& rangeSuffixLength)
 {
     // The format of "Range" header is defined in RFC 2616 Section 14.35.1.
     // http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.35.1
@@ -678,9 +678,9 @@
     static const unsigned bytesLength = 6;
     if (!startsWithLettersIgnoringASCIICase(range, "bytes="))
         return false;
-    // FIXME: The rest of this should use StringView.
-    String byteRange = range.substring(bytesLength);
 
+    StringView byteRange = range.substring(bytesLength);
+
     // The '-' character needs to be present.
     int index = byteRange.find('-');
     if (index == -1)
@@ -690,7 +690,7 @@
     // Example:
     //     -500
     if (!index) {
-        if (auto value = parseInteger<long long>(StringView { byteRange }.substring(index + 1)))
+        if (auto value = parseInteger<long long>(byteRange.substring(index + 1)))
             rangeSuffixLength = *value;
         return true;
     }
@@ -699,11 +699,11 @@
     // Examples:
     //     0-499
     //     500-
-    auto firstBytePos = parseInteger<long long>(StringView { byteRange }.left(index));
+    auto firstBytePos = parseInteger<long long>(byteRange.left(index));
     if (!firstBytePos)
         return false;
 
-    auto lastBytePosStr = stripLeadingAndTrailingHTTPSpaces(StringView { byteRange }.substring(index + 1));
+    auto lastBytePosStr = stripLeadingAndTrailingHTTPSpaces(byteRange.substring(index + 1));
     long long lastBytePos = -1;
     if (!lastBytePosStr.isEmpty()) {
         auto value = parseInteger<long long>(lastBytePosStr);

Modified: trunk/Source/WebCore/platform/network/HTTPParsers.h (292938 => 292939)


--- trunk/Source/WebCore/platform/network/HTTPParsers.h	2022-04-16 03:41:53 UTC (rev 292938)
+++ trunk/Source/WebCore/platform/network/HTTPParsers.h	2022-04-16 04:44:41 UTC (rev 292939)
@@ -88,7 +88,7 @@
 std::optional<std::pair<StringView, HashMap<String, String>>> parseStructuredFieldValue(StringView header);
 
 // -1 could be set to one of the return parameters to indicate the value is not specified.
-WEBCORE_EXPORT bool parseRange(const String&, long long& rangeOffset, long long& rangeEnd, long long& rangeSuffixLength);
+WEBCORE_EXPORT bool parseRange(StringView, long long& rangeOffset, long long& rangeEnd, long long& rangeSuffixLength);
 
 ContentTypeOptionsDisposition parseContentTypeOptionsHeader(StringView header);
 

Modified: trunk/Source/WebCore/platform/network/MIMEHeader.cpp (292938 => 292939)


--- trunk/Source/WebCore/platform/network/MIMEHeader.cpp	2022-04-16 03:41:53 UTC (rev 292938)
+++ trunk/Source/WebCore/platform/network/MIMEHeader.cpp	2022-04-16 04:44:41 UTC (rev 292939)
@@ -56,7 +56,7 @@
             break; // Empty line means end of key/value section.
         if (line[0] == '\t') {
             ASSERT(!key.isEmpty());
-            value.append(line.substring(1));
+            value.append(StringView(line).substring(1));
             continue;
         }
         // New key/value, store the previous one if any.

Modified: trunk/Source/WebCore/platform/network/ParsedContentType.cpp (292938 => 292939)


--- trunk/Source/WebCore/platform/network/ParsedContentType.cpp	2022-04-16 03:41:53 UTC (rev 292938)
+++ trunk/Source/WebCore/platform/network/ParsedContentType.cpp	2022-04-16 04:44:41 UTC (rev 292939)
@@ -365,9 +365,9 @@
     return m_parameterValues.size();
 }
 
-void ParsedContentType::setContentType(StringView contentRange, Mode mode)
+void ParsedContentType::setContentType(String&& contentRange, Mode mode)
 {
-    m_mimeType = contentRange.toString();
+    m_mimeType = WTFMove(contentRange);
     if (mode == Mode::MimeSniff)
         m_mimeType = stripLeadingAndTrailingHTTPSpaces(m_mimeType).convertToASCIILowercase();
     else

Modified: trunk/Source/WebCore/platform/network/ParsedContentType.h (292938 => 292939)


--- trunk/Source/WebCore/platform/network/ParsedContentType.h	2022-04-16 03:41:53 UTC (rev 292938)
+++ trunk/Source/WebCore/platform/network/ParsedContentType.h	2022-04-16 04:44:41 UTC (rev 292939)
@@ -63,7 +63,7 @@
     ParsedContentType(const ParsedContentType&) = delete;
     ParsedContentType& operator=(ParsedContentType const&) = delete;
     bool parseContentType(Mode);
-    void setContentType(StringView, Mode);
+    void setContentType(String&&, Mode);
     void setContentTypeParameter(const String&, const String&, Mode);
 
     typedef HashMap<String, String> KeyValuePairs;

Modified: trunk/Source/WebCore/rendering/RenderListMarker.cpp (292938 => 292939)


--- trunk/Source/WebCore/rendering/RenderListMarker.cpp	2022-04-16 03:41:53 UTC (rev 292938)
+++ trunk/Source/WebCore/rendering/RenderListMarker.cpp	2022-04-16 04:44:41 UTC (rev 292939)
@@ -1562,13 +1562,13 @@
             if (style().listStyleType() == ListStyleType::DisclosureClosed)
                 textForRun = { &blackLeftPointingSmallTriangle, 1 };
             else
-                textForRun = makeString(reversed(m_textWithSuffix.substring(m_textWithoutSuffixLength)), m_textWithSuffix.left(m_textWithoutSuffixLength));
+                textForRun = makeString(reversed(StringView(m_textWithSuffix).substring(m_textWithoutSuffixLength)), m_textWithSuffix.left(m_textWithoutSuffixLength));
         }
     } else {
         if (!style().isLeftToRightDirection())
             textForRun = reversed(m_textWithSuffix);
         else
-            textForRun = makeString(reversed(m_textWithSuffix.left(m_textWithoutSuffixLength)), m_textWithSuffix.substring(m_textWithoutSuffixLength));
+            textForRun = makeString(reversed(StringView(m_textWithSuffix).left(m_textWithoutSuffixLength)), m_textWithSuffix.substring(m_textWithoutSuffixLength));
     }
     auto textRun = RenderBlock::constructTextRun(textForRun, style());
     return { WTFMove(textRun), WTFMove(textForRun) };

Modified: trunk/Source/WebKit/ChangeLog (292938 => 292939)


--- trunk/Source/WebKit/ChangeLog	2022-04-16 03:41:53 UTC (rev 292938)
+++ trunk/Source/WebKit/ChangeLog	2022-04-16 04:44:41 UTC (rev 292939)
@@ -1,3 +1,17 @@
+2022-04-15  Chris Dumez  <cdu...@apple.com>
+
+        Leverage StringView in more places to avoid some String allocations
+        https://bugs.webkit.org/show_bug.cgi?id=239356
+
+        Reviewed by Darin Adler.
+
+        * Platform/cocoa/ImageAnalysisUtilities.mm:
+        (WebKit::makeTextRecognitionResult):
+        * UIProcess/Cocoa/MediaPermissionUtilities.mm:
+        (WebKit::visibleDomain):
+        * WebProcess/Plugins/PluginView.cpp:
+        (WebKit::PluginView::performJavaScriptURLRequest):
+
 2022-04-15  Wenson Hsieh  <wenson_hs...@apple.com>
 
         Add a helper function to perform additional setup on VKCImageAnalysis(Interaction|OverlayView)

Modified: trunk/Source/WebKit/Platform/cocoa/ImageAnalysisUtilities.mm (292938 => 292939)


--- trunk/Source/WebKit/Platform/cocoa/ImageAnalysisUtilities.mm	2022-04-16 03:41:53 UTC (rev 292938)
+++ trunk/Source/WebKit/Platform/cocoa/ImageAnalysisUtilities.mm	2022-04-16 04:44:41 UTC (rev 292939)
@@ -104,7 +104,7 @@
                 if (matchLocation == searchLocation)
                     return !isFirstLine && !searchLocation;
 
-                auto textBeforeMatch = lineText.substring(searchLocation, matchLocation - searchLocation);
+                auto textBeforeMatch = StringView(lineText).substring(searchLocation, matchLocation - searchLocation);
                 return !textBeforeMatch.isEmpty() && isSpaceOrNewline(textBeforeMatch[0]);
             })();
 

Modified: trunk/Source/WebKit/UIProcess/Cocoa/MediaPermissionUtilities.mm (292938 => 292939)


--- trunk/Source/WebKit/UIProcess/Cocoa/MediaPermissionUtilities.mm	2022-04-16 03:41:53 UTC (rev 292938)
+++ trunk/Source/WebKit/UIProcess/Cocoa/MediaPermissionUtilities.mm	2022-04-16 04:44:41 UTC (rev 292939)
@@ -109,7 +109,7 @@
 static NSString* visibleDomain(const String& host)
 {
     auto domain = WTF::URLHelpers::userVisibleURL(host.utf8());
-    return startsWithLettersIgnoringASCIICase(domain, "www.") ? domain.substring(4) : domain;
+    return startsWithLettersIgnoringASCIICase(domain, "www.") ? StringView(domain).substring(4).createNSString().autorelease() : static_cast<NSString *>(domain);
 }
 
 NSString *applicationVisibleNameFromOrigin(const WebCore::SecurityOriginData& origin)

Modified: trunk/Source/WebKit/WebProcess/Plugins/PluginView.cpp (292938 => 292939)


--- trunk/Source/WebKit/WebProcess/Plugins/PluginView.cpp	2022-04-16 03:41:53 UTC (rev 292938)
+++ trunk/Source/WebKit/WebProcess/Plugins/PluginView.cpp	2022-04-16 04:44:41 UTC (rev 292939)
@@ -1080,7 +1080,8 @@
     if (!frame)
         return;
     
-    String jsString = PAL::decodeURLEscapeSequences(request->request().url().string().substring(sizeof("_javascript_:") - 1));
+    auto urlString = request->request().url().string();
+    String jsString = PAL::decodeURLEscapeSequences(StringView(urlString).substring(sizeof("_javascript_:") - 1));
 
     if (!request->target().isNull()) {
         // For security reasons, only allow JS requests to be made on the frame that contains the plug-in.

Modified: trunk/Source/WebKitLegacy/mac/ChangeLog (292938 => 292939)


--- trunk/Source/WebKitLegacy/mac/ChangeLog	2022-04-16 03:41:53 UTC (rev 292938)
+++ trunk/Source/WebKitLegacy/mac/ChangeLog	2022-04-16 04:44:41 UTC (rev 292939)
@@ -1,3 +1,13 @@
+2022-04-15  Chris Dumez  <cdu...@apple.com>
+
+        Leverage StringView in more places to avoid some String allocations
+        https://bugs.webkit.org/show_bug.cgi?id=239356
+
+        Reviewed by Darin Adler.
+
+        * Misc/WebUserContentURLPattern.mm:
+        (-[WebUserContentURLPattern initWithPatternString:]):
+
 2022-04-15  Yusuke Suzuki  <ysuz...@apple.com>
 
         [JSC] Remove VM& parameter from structure related code including jsDyamicCast

Modified: trunk/Source/WebKitLegacy/mac/Misc/WebUserContentURLPattern.mm (292938 => 292939)


--- trunk/Source/WebKitLegacy/mac/Misc/WebUserContentURLPattern.mm	2022-04-16 03:41:53 UTC (rev 292938)
+++ trunk/Source/WebKitLegacy/mac/Misc/WebUserContentURLPattern.mm	2022-04-16 04:44:41 UTC (rev 292939)
@@ -48,7 +48,7 @@
         return nil;
 
     _private = [[WebUserContentURLPatternPrivate alloc] init];
-    _private->pattern = UserContentURLPattern(patternString);
+    _private->pattern = UserContentURLPattern(String(patternString));
 
     return self;
 }
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to