Title: [295214] trunk/Source
Revision
295214
Author
[email protected]
Date
2022-06-03 09:13:00 -0700 (Fri, 03 Jun 2022)

Log Message

Drop unnecessary operator==() overloads for String
https://bugs.webkit.org/show_bug.cgi?id=241235

Reviewed by Alex Christensen.

* Source/WTF/wtf/text/WTFString.h:
(WTF::operator==):
(WTF::operator!=):

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

Modified Paths

Diff

Modified: trunk/Source/_javascript_Core/inspector/agents/InspectorDebuggerAgent.cpp (295213 => 295214)


--- trunk/Source/_javascript_Core/inspector/agents/InspectorDebuggerAgent.cpp	2022-06-03 15:55:01 UTC (rev 295213)
+++ trunk/Source/_javascript_Core/inspector/agents/InspectorDebuggerAgent.cpp	2022-06-03 16:13:00 UTC (rev 295214)
@@ -939,15 +939,15 @@
     RefPtr<JSC::Breakpoint> allExceptionsBreakpoint;
     RefPtr<JSC::Breakpoint> uncaughtExceptionsBreakpoint;
 
-    if (stateString == "all") {
+    if (stateString == "all"_s) {
         allExceptionsBreakpoint = debuggerBreakpointFromPayload(errorString, WTFMove(options));
         if (!allExceptionsBreakpoint)
             return makeUnexpected(errorString);
-    } else if (stateString == "uncaught") {
+    } else if (stateString == "uncaught"_s) {
         uncaughtExceptionsBreakpoint = debuggerBreakpointFromPayload(errorString, WTFMove(options));
         if (!uncaughtExceptionsBreakpoint)
             return makeUnexpected(errorString);
-    } else if (stateString != "none")
+    } else if (stateString != "none"_s)
         return makeUnexpected(makeString("Unknown state: "_s, stateString));
 
     m_debugger.setPauseOnAllExceptionsBreakpoint(WTFMove(allExceptionsBreakpoint));

Modified: trunk/Source/_javascript_Core/jsc.cpp (295213 => 295214)


--- trunk/Source/_javascript_Core/jsc.cpp	2022-06-03 15:55:01 UTC (rev 295213)
+++ trunk/Source/_javascript_Core/jsc.cpp	2022-06-03 16:13:00 UTC (rev 295214)
@@ -1668,7 +1668,7 @@
     if (callFrame->argumentCount() > 1) {
         String type = callFrame->argument(1).toWTFString(globalObject);
         RETURN_IF_EXCEPTION(scope, encodedJSValue());
-        if (type != "binary")
+        if (type != "binary"_s)
             return throwVMError(globalObject, scope, "Expected 'binary' as second argument."_s);
         isBinary = true;
     }

Modified: trunk/Source/_javascript_Core/runtime/IntlCollator.cpp (295213 => 295214)


--- trunk/Source/_javascript_Core/runtime/IntlCollator.cpp	2022-06-03 15:55:01 UTC (rev 295213)
+++ trunk/Source/_javascript_Core/runtime/IntlCollator.cpp	2022-06-03 16:13:00 UTC (rev 295214)
@@ -188,7 +188,7 @@
     if (numeric != TriState::Indeterminate)
         localeOptions[static_cast<unsigned>(RelevantExtensionKey::Kn)] = String(numeric == TriState::True ? "true"_s : "false"_s);
 
-    String caseFirstOption = intlStringOption(globalObject, options, vm.propertyNames->caseFirst, { "upper", "lower", "false" }, "caseFirst must be either \"upper\", \"lower\", or \"false\""_s, { });
+    String caseFirstOption = intlStringOption(globalObject, options, vm.propertyNames->caseFirst, { "upper"_s, "lower"_s, "false"_s }, "caseFirst must be either \"upper\", \"lower\", or \"false\""_s, { });
     RETURN_IF_EXCEPTION(scope, void());
     if (!caseFirstOption.isNull())
         localeOptions[static_cast<unsigned>(RelevantExtensionKey::Kf)] = caseFirstOption;

Modified: trunk/Source/_javascript_Core/runtime/IntlDateTimeFormat.cpp (295213 => 295214)


--- trunk/Source/_javascript_Core/runtime/IntlDateTimeFormat.cpp	2022-06-03 15:55:01 UTC (rev 295213)
+++ trunk/Source/_javascript_Core/runtime/IntlDateTimeFormat.cpp	2022-06-03 16:13:00 UTC (rev 295214)
@@ -881,7 +881,7 @@
         break;
     }
 
-    intlStringOption(globalObject, options, vm.propertyNames->formatMatcher, { "basic", "best fit" }, "formatMatcher must be either \"basic\" or \"best fit\""_s, "best fit"_s);
+    intlStringOption(globalObject, options, vm.propertyNames->formatMatcher, { "basic"_s, "best fit"_s }, "formatMatcher must be either \"basic\" or \"best fit\""_s, "best fit"_s);
     RETURN_IF_EXCEPTION(scope, void());
 
     m_dateStyle = intlOption<DateTimeStyle>(globalObject, options, vm.propertyNames->dateStyle, { { "full"_s, DateTimeStyle::Full }, { "long"_s, DateTimeStyle::Long }, { "medium"_s, DateTimeStyle::Medium }, { "short"_s, DateTimeStyle::Short } }, "dateStyle must be \"full\", \"long\", \"medium\", or \"short\""_s, DateTimeStyle::None);

Modified: trunk/Source/_javascript_Core/runtime/IntlLocale.cpp (295213 => 295214)


--- trunk/Source/_javascript_Core/runtime/IntlLocale.cpp	2022-06-03 15:55:01 UTC (rev 295213)
+++ trunk/Source/_javascript_Core/runtime/IntlLocale.cpp	2022-06-03 16:13:00 UTC (rev 295214)
@@ -295,12 +295,12 @@
         localeID.setKeywordValue("collation"_s, collation);
     }
 
-    String hourCycle = intlStringOption(globalObject, options, vm.propertyNames->hourCycle, { "h11", "h12", "h23", "h24" }, "hourCycle must be \"h11\", \"h12\", \"h23\", or \"h24\""_s, { });
+    String hourCycle = intlStringOption(globalObject, options, vm.propertyNames->hourCycle, { "h11"_s, "h12"_s, "h23"_s, "h24"_s }, "hourCycle must be \"h11\", \"h12\", \"h23\", or \"h24\""_s, { });
     RETURN_IF_EXCEPTION(scope, void());
     if (!hourCycle.isNull())
         localeID.setKeywordValue("hours"_s, hourCycle);
 
-    String caseFirst = intlStringOption(globalObject, options, vm.propertyNames->caseFirst, { "upper", "lower", "false" }, "caseFirst must be either \"upper\", \"lower\", or \"false\""_s, { });
+    String caseFirst = intlStringOption(globalObject, options, vm.propertyNames->caseFirst, { "upper"_s, "lower"_s, "false"_s }, "caseFirst must be either \"upper\", \"lower\", or \"false\""_s, { });
     RETURN_IF_EXCEPTION(scope, void());
     if (!caseFirst.isNull())
         localeID.setKeywordValue("colcasefirst"_s, caseFirst);

Modified: trunk/Source/_javascript_Core/runtime/IntlObject.cpp (295213 => 295214)


--- trunk/Source/_javascript_Core/runtime/IntlObject.cpp	2022-06-03 15:55:01 UTC (rev 295213)
+++ trunk/Source/_javascript_Core/runtime/IntlObject.cpp	2022-06-03 16:13:00 UTC (rev 295214)
@@ -588,7 +588,7 @@
     return triState(value.toBoolean(globalObject));
 }
 
-String intlStringOption(JSGlobalObject* globalObject, JSObject* options, PropertyName property, std::initializer_list<const char*> values, ASCIILiteral notFound, ASCIILiteral fallback)
+String intlStringOption(JSGlobalObject* globalObject, JSObject* options, PropertyName property, std::initializer_list<ASCIILiteral> values, ASCIILiteral notFound, ASCIILiteral fallback)
 {
     // GetOption (options, property, type="string", values, fallback)
     // https://tc39.github.io/ecma402/#sec-getoption

Modified: trunk/Source/_javascript_Core/runtime/IntlObject.h (295213 => 295214)


--- trunk/Source/_javascript_Core/runtime/IntlObject.h	2022-06-03 15:55:01 UTC (rev 295213)
+++ trunk/Source/_javascript_Core/runtime/IntlObject.h	2022-06-03 16:13:00 UTC (rev 295214)
@@ -122,7 +122,7 @@
 CalendarID utcTimeZoneID();
 
 TriState intlBooleanOption(JSGlobalObject*, JSObject* options, PropertyName);
-String intlStringOption(JSGlobalObject*, JSObject* options, PropertyName, std::initializer_list<const char*> values, ASCIILiteral notFound, ASCIILiteral fallback);
+String intlStringOption(JSGlobalObject*, JSObject* options, PropertyName, std::initializer_list<ASCIILiteral> values, ASCIILiteral notFound, ASCIILiteral fallback);
 unsigned intlNumberOption(JSGlobalObject*, JSObject* options, PropertyName, unsigned minimum, unsigned maximum, unsigned fallback);
 unsigned intlDefaultNumberOption(JSGlobalObject*, JSValue, PropertyName, unsigned minimum, unsigned maximum, unsigned fallback);
 Vector<char, 32> localeIDBufferForLanguageTagWithNullTerminator(const CString&);

Modified: trunk/Source/_javascript_Core/runtime/TemporalObject.cpp (295213 => 295214)


--- trunk/Source/_javascript_Core/runtime/TemporalObject.cpp	2022-06-03 15:55:01 UTC (rev 295213)
+++ trunk/Source/_javascript_Core/runtime/TemporalObject.cpp	2022-06-03 16:13:00 UTC (rev 295214)
@@ -306,7 +306,7 @@
     String stringValue = value.toWTFString(globalObject);
     RETURN_IF_EXCEPTION(scope, std::nullopt);
 
-    if (stringValue != "auto")
+    if (stringValue != "auto"_s)
         throwRangeError(globalObject, scope, makeString("fractionalSecondDigits must be 'auto' or 0 through 9, not "_s, ellipsizeAt(100, stringValue)));
 
     return std::nullopt;

Modified: trunk/Source/WTF/wtf/text/WTFString.h (295213 => 295214)


--- trunk/Source/WTF/wtf/text/WTFString.h	2022-06-03 15:55:01 UTC (rev 295213)
+++ trunk/Source/WTF/wtf/text/WTFString.h	2022-06-03 16:13:00 UTC (rev 295214)
@@ -335,19 +335,16 @@
 static_assert(sizeof(String) == sizeof(void*), "String should effectively be a pointer to a StringImpl, and efficient to pass by value");
 
 inline bool operator==(const String& a, const String& b) { return equal(a.impl(), b.impl()); }
-inline bool operator==(const String& a, const char* b) { return equal(a.impl(), reinterpret_cast<const LChar*>(b)); }
 inline bool operator==(const String& a, ASCIILiteral b) { return equal(a.impl(), b); }
-inline bool operator==(const LChar* a, const String& b) { return equal(a, b.impl()); }
-inline bool operator==(const char* a, const String& b) { return equal(reinterpret_cast<const LChar*>(a), b.impl()); }
 inline bool operator==(ASCIILiteral a, const String& b) { return equal(b.impl(), a); }
 template<size_t inlineCapacity> inline bool operator==(const Vector<char, inlineCapacity>& a, const String& b) { return equal(b.impl(), a.data(), a.size()); }
 template<size_t inlineCapacity> inline bool operator==(const String& a, const Vector<char, inlineCapacity>& b) { return b == a; }
 
+// FIXME: we should fix call sites and drop this overload.
+inline bool operator==(const String& a, const char* b) { return equal(a.impl(), reinterpret_cast<const LChar*>(b)); }
+
 inline bool operator!=(const String& a, const String& b) { return !equal(a.impl(), b.impl()); }
-inline bool operator!=(const String& a, const char* b) { return !equal(a.impl(), reinterpret_cast<const LChar*>(b)); }
 inline bool operator!=(const String& a, ASCIILiteral b) { return !equal(a.impl(), b); }
-inline bool operator!=(const LChar* a, const String& b) { return !equal(a, b.impl()); }
-inline bool operator!=(const char* a, const String& b) { return !equal(reinterpret_cast<const LChar*>(a), b.impl()); }
 inline bool operator!=(ASCIILiteral a, const String& b) { return !equal(b.impl(), a); }
 template<size_t inlineCapacity> inline bool operator!=(const Vector<char, inlineCapacity>& a, const String& b) { return !(a == b); }
 template<size_t inlineCapacity> inline bool operator!=(const String& a, const Vector<char, inlineCapacity>& b) { return b != a; }
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to