- Revision
- 291848
- Author
- [email protected]
- Date
- 2022-03-24 21:21:48 -0700 (Thu, 24 Mar 2022)
Log Message
String::split() should take in a StringView instead of a String
https://bugs.webkit.org/show_bug.cgi?id=238355
Reviewed by Geoffrey Garen.
Source/WebCore:
* accessibility/isolatedtree/AXIsolatedObject.cpp:
(WebCore::AXIsolatedObject::classList const):
Call the more efficient split(UChar) overload instead.
Source/WebKit:
* UIProcess/Inspector/socket/RemoteInspectorProtocolHandler.cpp:
Optimize by calling StringView::split() instead of String::split().
Source/WTF:
String::split() should take in a StringView instead of a String, to avoid unnecessary construction
of Strings in some instances.
* wtf/text/WTFString.cpp:
(WTF::String::splitInternal const):
(WTF::String::split const):
(WTF::String::splitAllowingEmptyEntries const):
* wtf/text/WTFString.h:
Modified Paths
Diff
Modified: trunk/Source/WTF/ChangeLog (291847 => 291848)
--- trunk/Source/WTF/ChangeLog 2022-03-25 04:14:29 UTC (rev 291847)
+++ trunk/Source/WTF/ChangeLog 2022-03-25 04:21:48 UTC (rev 291848)
@@ -1,5 +1,21 @@
2022-03-24 Chris Dumez <[email protected]>
+ String::split() should take in a StringView instead of a String
+ https://bugs.webkit.org/show_bug.cgi?id=238355
+
+ Reviewed by Geoffrey Garen.
+
+ String::split() should take in a StringView instead of a String, to avoid unnecessary construction
+ of Strings in some instances.
+
+ * wtf/text/WTFString.cpp:
+ (WTF::String::splitInternal const):
+ (WTF::String::split const):
+ (WTF::String::splitAllowingEmptyEntries const):
+ * wtf/text/WTFString.h:
+
+2022-03-24 Chris Dumez <[email protected]>
+
FileSystem::pathByAppendingComponent() should take in StringViews instead of Strings
https://bugs.webkit.org/show_bug.cgi?id=238344
Modified: trunk/Source/WTF/wtf/text/WTFString.cpp (291847 => 291848)
--- trunk/Source/WTF/wtf/text/WTFString.cpp 2022-03-25 04:14:29 UTC (rev 291847)
+++ trunk/Source/WTF/wtf/text/WTFString.cpp 2022-03-25 04:21:48 UTC (rev 291848)
@@ -532,7 +532,7 @@
}
template<bool allowEmptyEntries>
-inline Vector<String> String::splitInternal(const String& separator) const
+inline Vector<String> String::splitInternal(StringView separator) const
{
Vector<String> result;
@@ -586,7 +586,7 @@
return splitInternal<false>(separator);
}
-Vector<String> String::split(const String& separator) const
+Vector<String> String::split(StringView separator) const
{
return splitInternal<false>(separator);
}
@@ -601,7 +601,7 @@
return splitInternal<true>(separator);
}
-Vector<String> String::splitAllowingEmptyEntries(const String& separator) const
+Vector<String> String::splitAllowingEmptyEntries(StringView separator) const
{
return splitInternal<true>(separator);
}
Modified: trunk/Source/WTF/wtf/text/WTFString.h (291847 => 291848)
--- trunk/Source/WTF/wtf/text/WTFString.h 2022-03-25 04:14:29 UTC (rev 291847)
+++ trunk/Source/WTF/wtf/text/WTFString.h 2022-03-25 04:21:48 UTC (rev 291848)
@@ -243,11 +243,11 @@
WTF_EXPORT_PRIVATE void split(UChar separator, const SplitFunctor&) const;
WTF_EXPORT_PRIVATE Vector<String> split(UChar separator) const;
- WTF_EXPORT_PRIVATE Vector<String> split(const String& separator) const;
+ WTF_EXPORT_PRIVATE Vector<String> split(StringView separator) const;
WTF_EXPORT_PRIVATE void splitAllowingEmptyEntries(UChar separator, const SplitFunctor&) const;
WTF_EXPORT_PRIVATE Vector<String> splitAllowingEmptyEntries(UChar separator) const;
- WTF_EXPORT_PRIVATE Vector<String> splitAllowingEmptyEntries(const String& separator) const;
+ WTF_EXPORT_PRIVATE Vector<String> splitAllowingEmptyEntries(StringView separator) const;
WTF_EXPORT_PRIVATE double toDouble(bool* ok = nullptr) const;
WTF_EXPORT_PRIVATE float toFloat(bool* ok = nullptr) const;
@@ -343,7 +343,7 @@
template<bool allowEmptyEntries> void splitInternal(UChar separator, const SplitFunctor&) const;
template<bool allowEmptyEntries> Vector<String> splitInternal(UChar separator) const;
- template<bool allowEmptyEntries> Vector<String> splitInternal(const String& separator) const;
+ template<bool allowEmptyEntries> Vector<String> splitInternal(StringView separator) const;
RefPtr<StringImpl> m_impl;
};
Modified: trunk/Source/WebCore/ChangeLog (291847 => 291848)
--- trunk/Source/WebCore/ChangeLog 2022-03-25 04:14:29 UTC (rev 291847)
+++ trunk/Source/WebCore/ChangeLog 2022-03-25 04:21:48 UTC (rev 291848)
@@ -1,3 +1,14 @@
+2022-03-24 Chris Dumez <[email protected]>
+
+ String::split() should take in a StringView instead of a String
+ https://bugs.webkit.org/show_bug.cgi?id=238355
+
+ Reviewed by Geoffrey Garen.
+
+ * accessibility/isolatedtree/AXIsolatedObject.cpp:
+ (WebCore::AXIsolatedObject::classList const):
+ Call the more efficient split(UChar) overload instead.
+
2022-03-24 Myles C. Maxfield <[email protected]>
[Cocoa] REGRESSION(r281291): When accessibility bold is enabled, font-family:system-ui is supposed to be bold
Modified: trunk/Source/WebCore/accessibility/isolatedtree/AXIsolatedObject.cpp (291847 => 291848)
--- trunk/Source/WebCore/accessibility/isolatedtree/AXIsolatedObject.cpp 2022-03-25 04:14:29 UTC (rev 291847)
+++ trunk/Source/WebCore/accessibility/isolatedtree/AXIsolatedObject.cpp 2022-03-25 04:21:48 UTC (rev 291848)
@@ -600,7 +600,7 @@
void AXIsolatedObject::classList(Vector<String>& list) const
{
String classList = stringAttributeValue(AXPropertyName::ClassList);
- list.appendVector(classList.split(" "));
+ list.appendVector(classList.split(' '));
}
PAL::SessionID AXIsolatedObject::sessionID() const
Modified: trunk/Source/WebKit/ChangeLog (291847 => 291848)
--- trunk/Source/WebKit/ChangeLog 2022-03-25 04:14:29 UTC (rev 291847)
+++ trunk/Source/WebKit/ChangeLog 2022-03-25 04:21:48 UTC (rev 291848)
@@ -1,3 +1,13 @@
+2022-03-24 Chris Dumez <[email protected]>
+
+ String::split() should take in a StringView instead of a String
+ https://bugs.webkit.org/show_bug.cgi?id=238355
+
+ Reviewed by Geoffrey Garen.
+
+ * UIProcess/Inspector/socket/RemoteInspectorProtocolHandler.cpp:
+ Optimize by calling StringView::split() instead of String::split().
+
2022-03-24 Brent Fulgham <[email protected]>
Require click-to-play for media in Captive Portals
Modified: trunk/Source/WebKit/UIProcess/Inspector/socket/RemoteInspectorProtocolHandler.cpp (291847 => 291848)
--- trunk/Source/WebKit/UIProcess/Inspector/socket/RemoteInspectorProtocolHandler.cpp 2022-03-25 04:14:29 UTC (rev 291847)
+++ trunk/Source/WebKit/UIProcess/Inspector/socket/RemoteInspectorProtocolHandler.cpp 2022-03-25 04:21:48 UTC (rev 291848)
@@ -55,12 +55,28 @@
void didPostMessage(WebPageProxy& page, FrameInfoData&&, API::ContentWorld&, WebCore::SerializedScriptValue& serializedScriptValue) override
{
- auto tokens = serializedScriptValue.toString().split(":");
- if (tokens.size() != 3)
+ auto valueAsString = serializedScriptValue.toString();
+ auto tokens = StringView { valueAsString }.split(':');
+ uint32_t connectionID = 0;
+ uint32_t targetID = 0;
+ String type;
+ int i = 0;
+ for (auto token : tokens) {
+ if (!i)
+ connectionID = parseInteger<uint32_t>(token).value_or(0);
+ else if (i == 1)
+ targetID = parseInteger<uint32_t>(token).value_or(0);
+ else if (i == 2)
+ type = token.toString();
+ else
+ return;
+ ++i;
+ }
+ if (i != 3)
return;
URL requestURL { page.pageLoadState().url() };
- m_inspectorProtocolHandler.inspect(requestURL.hostAndPort(), parseInteger<uint32_t>(tokens[0]).value_or(0), parseInteger<uint32_t>(tokens[1]).value_or(0), tokens[2]);
+ m_inspectorProtocolHandler.inspect(requestURL.hostAndPort(), connectionID, targetID, type);
}
bool supportsAsyncReply() override