Title: [293763] trunk
Revision
293763
Author
cdu...@apple.com
Date
2022-05-04 00:02:57 -0700 (Wed, 04 May 2022)

Log Message

Drop StringImpl::createFromLiteral()
https://bugs.webkit.org/show_bug.cgi?id=239792

Reviewed by Darin Adler.

Drop StringImpl::createFromLiteral().

Call sites that have an ASCIILiteral can now simply call StringImpl::create(ASCIILiteral).
Call sites that have raw characters can call the existing StringImpl::createWithoutCopying().

This simplifies our API a bit.

Also inline part of the createWithoutCopying() functions so that the 0-length check is
inline. This allows the compiler to optimize the check out when the length is known at
compile time (which is often the case with literals).

* Tools/TestWebKitAPI/Tests/WTF/StringImpl.cpp:
(TestWebKitAPI::TEST):
* Source/_javascript_Core/API/JSScriptRef.cpp:
* Source/_javascript_Core/Scripts/wkbuiltins/builtins_templates.py:
* Source/_javascript_Core/builtins/BuiltinExecutables.cpp:
(JSC::BuiltinExecutables::BuiltinExecutables):
* Source/_javascript_Core/runtime/IntlObject.cpp:
(JSC::availableUnits):
* Source/WTF/wtf/text/StringImpl.cpp:
(WTF::StringImpl::createWithoutCopyingNonEmpty):
(WTF::StringImpl::createFromLiteral): Deleted.
(WTF::StringImpl::createWithoutCopying): Deleted.
* Source/WTF/wtf/text/StringImpl.h:
(WTF::StringImpl::create):
(WTF::StringImpl::createWithoutCopying):
(WTF::StringImpl::createFromLiteral): Deleted.
* Source/WTF/wtf/text/WTFString.h:
(WTF::String::String):
* Source/WebCore/rendering/mathml/RenderMathMLFenced.cpp:
(WebCore::RenderMathMLFenced::updateFromElement):

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

Modified Paths

Diff

Modified: trunk/Source/_javascript_Core/API/JSScriptRef.cpp (293762 => 293763)


--- trunk/Source/_javascript_Core/API/JSScriptRef.cpp	2022-05-04 06:25:05 UTC (rev 293762)
+++ trunk/Source/_javascript_Core/API/JSScriptRef.cpp	2022-05-04 07:02:57 UTC (rev 293763)
@@ -92,7 +92,7 @@
     startingLineNumber = std::max(1, startingLineNumber);
 
     auto sourceURL = urlString ? URL({ }, urlString->string()) : URL();
-    auto result = OpaqueJSScript::create(vm, SourceOrigin { sourceURL }, sourceURL.string(), startingLineNumber, String(StringImpl::createFromLiteral(source, length)));
+    auto result = OpaqueJSScript::create(vm, SourceOrigin { sourceURL }, sourceURL.string(), startingLineNumber, String(StringImpl::createWithoutCopying(source, length)));
 
     ParserError error;
     if (!parseScript(vm, SourceCode(result.copyRef()), error)) {

Modified: trunk/Source/_javascript_Core/Scripts/wkbuiltins/builtins_templates.py (293762 => 293763)


--- trunk/Source/_javascript_Core/Scripts/wkbuiltins/builtins_templates.py	2022-05-04 06:25:05 UTC (rev 293762)
+++ trunk/Source/_javascript_Core/Scripts/wkbuiltins/builtins_templates.py	2022-05-04 07:02:57 UTC (rev 293763)
@@ -132,7 +132,7 @@
     explicit ${objectName}BuiltinsWrapper(JSC::VM& vm)
         : m_vm(vm)
         ${macroPrefix}_FOREACH_${objectMacro}_BUILTIN_FUNCTION_NAME(INITIALIZE_BUILTIN_NAMES)
-#define INITIALIZE_BUILTIN_SOURCE_MEMBERS(name, functionName, overriddenName, length) , m_##name##Source(JSC::makeSource(StringImpl::createFromLiteral(s_##name, length), { }))
+#define INITIALIZE_BUILTIN_SOURCE_MEMBERS(name, functionName, overriddenName, length) , m_##name##Source(JSC::makeSource(StringImpl::createWithoutCopying(s_##name, length), { }))
         ${macroPrefix}_FOREACH_${objectMacro}_BUILTIN_CODE(INITIALIZE_BUILTIN_SOURCE_MEMBERS)
 #undef INITIALIZE_BUILTIN_SOURCE_MEMBERS
     {

Modified: trunk/Source/_javascript_Core/builtins/BuiltinExecutables.cpp (293762 => 293763)


--- trunk/Source/_javascript_Core/builtins/BuiltinExecutables.cpp	2022-05-04 06:25:05 UTC (rev 293762)
+++ trunk/Source/_javascript_Core/builtins/BuiltinExecutables.cpp	2022-05-04 07:02:57 UTC (rev 293763)
@@ -36,7 +36,7 @@
 
 BuiltinExecutables::BuiltinExecutables(VM& vm)
     : m_vm(vm)
-    , m_combinedSourceProvider(StringSourceProvider::create(StringImpl::createFromLiteral(s_JSCCombinedCode, s_JSCCombinedCodeLength), { }, String()))
+    , m_combinedSourceProvider(StringSourceProvider::create(StringImpl::createWithoutCopying(s_JSCCombinedCode, s_JSCCombinedCodeLength), { }, String()))
 {
 }
 

Modified: trunk/Source/_javascript_Core/runtime/IntlObject.cpp (293762 => 293763)


--- trunk/Source/_javascript_Core/runtime/IntlObject.cpp	2022-05-04 06:25:05 UTC (rev 293762)
+++ trunk/Source/_javascript_Core/runtime/IntlObject.cpp	2022-05-04 07:02:57 UTC (rev 293763)
@@ -1899,7 +1899,7 @@
 
     int32_t index = 0;
     for (const MeasureUnit& unit : simpleUnits) {
-        result->putDirectIndex(globalObject, index++, jsString(vm, StringImpl::createFromLiteral(unit.subType)));
+        result->putDirectIndex(globalObject, index++, jsString(vm, StringImpl::create(unit.subType)));
         RETURN_IF_EXCEPTION(scope, { });
     }
     return result;

Modified: trunk/Source/WTF/wtf/text/StringImpl.cpp (293762 => 293763)


--- trunk/Source/WTF/wtf/text/StringImpl.cpp	2022-05-04 06:25:05 UTC (rev 293762)
+++ trunk/Source/WTF/wtf/text/StringImpl.cpp	2022-05-04 07:02:57 UTC (rev 293763)
@@ -151,29 +151,15 @@
     StringImplMalloc::free(stringImpl);
 }
 
-Ref<StringImpl> StringImpl::createFromLiteral(const char* characters, unsigned length)
+Ref<StringImpl> StringImpl::createWithoutCopyingNonEmpty(const UChar* characters, unsigned length)
 {
-    ASSERT_WITH_MESSAGE(length, "Use StringImpl::empty() to create an empty string");
-    ASSERT(charactersAreAllASCII(reinterpret_cast<const LChar*>(characters), length));
-    return adoptRef(*new StringImpl(reinterpret_cast<const LChar*>(characters), length, ConstructWithoutCopying));
-}
-
-Ref<StringImpl> StringImpl::createFromLiteral(const char* characters)
-{
-    return createFromLiteral(characters, strlen(characters));
-}
-
-Ref<StringImpl> StringImpl::createWithoutCopying(const UChar* characters, unsigned length)
-{
-    if (!length)
-        return *empty();
+    ASSERT(length);
     return adoptRef(*new StringImpl(characters, length, ConstructWithoutCopying));
 }
 
-Ref<StringImpl> StringImpl::createWithoutCopying(const LChar* characters, unsigned length)
+Ref<StringImpl> StringImpl::createWithoutCopyingNonEmpty(const LChar* characters, unsigned length)
 {
-    if (!length)
-        return *empty();
+    ASSERT(length);
     return adoptRef(*new StringImpl(characters, length, ConstructWithoutCopying));
 }
 

Modified: trunk/Source/WTF/wtf/text/StringImpl.h (293762 => 293763)


--- trunk/Source/WTF/wtf/text/StringImpl.h	2022-05-04 06:25:05 UTC (rev 293762)
+++ trunk/Source/WTF/wtf/text/StringImpl.h	2022-05-04 07:02:57 UTC (rev 293763)
@@ -246,14 +246,12 @@
 
     static Ref<StringImpl> createSubstringSharingImpl(StringImpl&, unsigned offset, unsigned length);
 
-    // FIXME: Replace calls to these overloads of createFromLiteral to createWithoutCopying instead.
-    WTF_EXPORT_PRIVATE static Ref<StringImpl> createFromLiteral(const char*, unsigned length);
-    WTF_EXPORT_PRIVATE static Ref<StringImpl> createFromLiteral(const char*);
-    static Ref<StringImpl> createFromLiteral(ASCIILiteral);
+    ALWAYS_INLINE static Ref<StringImpl> create(ASCIILiteral literal) { return createWithoutCopying(literal.characters8(), literal.length()); }
 
-    WTF_EXPORT_PRIVATE static Ref<StringImpl> createWithoutCopying(const UChar*, unsigned length);
-    WTF_EXPORT_PRIVATE static Ref<StringImpl> createWithoutCopying(const LChar*, unsigned length);
-    static Ref<StringImpl> createWithoutCopying(const char* characters, unsigned length) { return createWithoutCopying(reinterpret_cast<const LChar*>(characters), length); }
+    static Ref<StringImpl> createWithoutCopying(const UChar* characters, unsigned length) { return length ? createWithoutCopyingNonEmpty(characters, length) : Ref { *empty() }; }
+    static Ref<StringImpl> createWithoutCopying(const LChar* characters, unsigned length) { return length ? createWithoutCopyingNonEmpty(characters, length) : Ref { *empty() }; }
+    ALWAYS_INLINE static Ref<StringImpl> createWithoutCopying(const char* characters, unsigned length) { return createWithoutCopying(reinterpret_cast<const LChar*>(characters), length); }
+
     WTF_EXPORT_PRIVATE static Ref<StringImpl> createUninitialized(unsigned length, LChar*&);
     WTF_EXPORT_PRIVATE static Ref<StringImpl> createUninitialized(unsigned length, UChar*&);
     template<typename CharacterType> static RefPtr<StringImpl> tryCreateUninitialized(unsigned length, CharacterType*&);
@@ -506,6 +504,9 @@
     enum class CaseConvertType { Upper, Lower };
     template<CaseConvertType, typename CharacterType> static Ref<StringImpl> convertASCIICase(StringImpl&, const CharacterType*, unsigned);
 
+    WTF_EXPORT_PRIVATE static Ref<StringImpl> createWithoutCopyingNonEmpty(const LChar*, unsigned length);
+    WTF_EXPORT_PRIVATE static Ref<StringImpl> createWithoutCopyingNonEmpty(const UChar*, unsigned length);
+
     template<class CodeUnitPredicate> Ref<StringImpl> stripMatchedCharacters(CodeUnitPredicate);
     template<typename CharacterType, typename Predicate> ALWAYS_INLINE Ref<StringImpl> removeCharactersImpl(const CharacterType* characters, const Predicate&);
     template<typename CharacterType, class CodeUnitPredicate> Ref<StringImpl> simplifyMatchedCharactersToSpace(CodeUnitPredicate);
@@ -980,12 +981,6 @@
     return adoptRef(*new (NotNull, stringImpl) StringImpl(rep.m_data16 + offset, length, *ownerRep));
 }
 
-inline Ref<StringImpl> StringImpl::createFromLiteral(ASCIILiteral literal)
-{
-    auto length = literal.length();
-    return length ? createFromLiteral(literal.characters(), length) : Ref { *StringImpl::empty() };
-}
-
 template<typename CharacterType> ALWAYS_INLINE RefPtr<StringImpl> StringImpl::tryCreateUninitialized(unsigned length, CharacterType*& output)
 {
     if (!length) {

Modified: trunk/Source/WTF/wtf/text/WTFString.h (293762 => 293763)


--- trunk/Source/WTF/wtf/text/WTFString.h	2022-05-04 06:25:05 UTC (rev 293762)
+++ trunk/Source/WTF/wtf/text/WTFString.h	2022-05-04 07:02:57 UTC (rev 293763)
@@ -446,7 +446,7 @@
 }
 
 inline String::String(ASCIILiteral characters)
-    : m_impl(characters.isNull() ? nullptr : RefPtr<StringImpl> { StringImpl::createFromLiteral(characters) })
+    : m_impl(characters.isNull() ? nullptr : RefPtr<StringImpl> { StringImpl::create(characters) })
 {
 }
 

Modified: trunk/Source/WebCore/rendering/mathml/RenderMathMLFenced.cpp (293762 => 293763)


--- trunk/Source/WebCore/rendering/mathml/RenderMathMLFenced.cpp	2022-05-04 06:25:05 UTC (rev 293762)
+++ trunk/Source/WebCore/rendering/mathml/RenderMathMLFenced.cpp	2022-05-04 07:02:57 UTC (rev 293763)
@@ -75,7 +75,7 @@
         m_separators = !characters.length() ? 0 : characters.toString().impl();
     } else {
         // The separator defaults to a single comma.
-        m_separators = StringImpl::createFromLiteral(","_s);
+        m_separators = StringImpl::create(","_s);
     }
 
     if (firstChild()) {

Modified: trunk/Tools/TestWebKitAPI/Tests/WTF/StringImpl.cpp (293762 => 293763)


--- trunk/Tools/TestWebKitAPI/Tests/WTF/StringImpl.cpp	2022-05-04 06:25:05 UTC (rev 293762)
+++ trunk/Tools/TestWebKitAPI/Tests/WTF/StringImpl.cpp	2022-05-04 07:02:57 UTC (rev 293763)
@@ -36,7 +36,7 @@
 TEST(WTF, StringImplCreationFromLiteral)
 {
     // Constructor taking an ASCIILiteral.
-    auto stringWithTemplate = StringImpl::createFromLiteral("Template Literal"_s);
+    auto stringWithTemplate = StringImpl::create("Template Literal"_s);
     ASSERT_EQ(strlen("Template Literal"), stringWithTemplate->length());
     ASSERT_TRUE(equal(stringWithTemplate.get(), "Template Literal"));
     ASSERT_TRUE(stringWithTemplate->is8Bit());
@@ -43,21 +43,13 @@
 
     // Constructor taking the size explicitly.
     const char* programmaticStringData = "Explicit Size Literal";
-    auto programmaticString = StringImpl::createFromLiteral(programmaticStringData, strlen(programmaticStringData));
+    auto programmaticString = StringImpl::createWithoutCopying(programmaticStringData, strlen(programmaticStringData));
     ASSERT_EQ(strlen(programmaticStringData), programmaticString->length());
     ASSERT_TRUE(equal(programmaticString.get(), programmaticStringData));
     ASSERT_EQ(programmaticStringData, reinterpret_cast<const char*>(programmaticString->characters8()));
     ASSERT_TRUE(programmaticString->is8Bit());
 
-    // Constructor without explicit size.
-    const char* stringWithoutLengthLiteral = "No Size Literal";
-    auto programmaticStringNoLength = StringImpl::createFromLiteral(stringWithoutLengthLiteral);
-    ASSERT_EQ(strlen(stringWithoutLengthLiteral), programmaticStringNoLength->length());
-    ASSERT_TRUE(equal(programmaticStringNoLength.get(), stringWithoutLengthLiteral));
-    ASSERT_EQ(stringWithoutLengthLiteral, reinterpret_cast<const char*>(programmaticStringNoLength->characters8()));
-    ASSERT_TRUE(programmaticStringNoLength->is8Bit());
-
-    // AtomStringImpl from createFromLiteral should use the same underlying string.
+    // AtomStringImpl from createWithoutCopying should use the same underlying string.
     auto atomStringWithTemplate = AtomStringImpl::add(stringWithTemplate.ptr());
     ASSERT_TRUE(atomStringWithTemplate->is8Bit());
     ASSERT_EQ(atomStringWithTemplate->characters8(), stringWithTemplate->characters8());
@@ -64,14 +56,11 @@
     auto atomicProgrammaticString = AtomStringImpl::add(programmaticString.ptr());
     ASSERT_TRUE(atomicProgrammaticString->is8Bit());
     ASSERT_EQ(atomicProgrammaticString->characters8(), programmaticString->characters8());
-    auto atomicProgrammaticStringNoLength = AtomStringImpl::add(programmaticStringNoLength.ptr());
-    ASSERT_TRUE(atomicProgrammaticStringNoLength->is8Bit());
-    ASSERT_EQ(atomicProgrammaticStringNoLength->characters8(), programmaticStringNoLength->characters8());
 }
 
 TEST(WTF, StringImplReplaceWithLiteral)
 {
-    auto testStringImpl = StringImpl::createFromLiteral("1224"_s);
+    auto testStringImpl = StringImpl::create("1224"_s);
     ASSERT_TRUE(testStringImpl->is8Bit());
 
     // Cases for 8Bit source.
@@ -78,7 +67,7 @@
     testStringImpl = testStringImpl->replace('2', "", 0);
     ASSERT_TRUE(equal(testStringImpl.get(), "14"));
 
-    testStringImpl = StringImpl::createFromLiteral("1224"_s);
+    testStringImpl = StringImpl::create("1224"_s);
     ASSERT_TRUE(testStringImpl->is8Bit());
 
     testStringImpl = testStringImpl->replace('3', "NotFound", 8);
@@ -87,7 +76,7 @@
     testStringImpl = testStringImpl->replace('2', "3", 1);
     ASSERT_TRUE(equal(testStringImpl.get(), "1334"));
 
-    testStringImpl = StringImpl::createFromLiteral("1224"_s);
+    testStringImpl = StringImpl::create("1224"_s);
     ASSERT_TRUE(testStringImpl->is8Bit());
     testStringImpl = testStringImpl->replace('2', "555", 3);
     ASSERT_TRUE(equal(testStringImpl.get(), "15555554"));
@@ -115,13 +104,13 @@
 
 TEST(WTF, StringImplEqualIgnoringASCIICaseBasic)
 {
-    auto a = StringImpl::createFromLiteral("aBcDeFG"_s);
-    auto b = StringImpl::createFromLiteral("ABCDEFG"_s);
-    auto c = StringImpl::createFromLiteral("abcdefg"_s);
+    auto a = StringImpl::create("aBcDeFG"_s);
+    auto b = StringImpl::create("ABCDEFG"_s);
+    auto c = StringImpl::create("abcdefg"_s);
     constexpr auto d = "aBcDeFG"_s;
     auto empty = StringImpl::create(reinterpret_cast<const LChar*>(""), 0);
-    auto shorter = StringImpl::createFromLiteral("abcdef"_s);
-    auto different = StringImpl::createFromLiteral("abcrefg"_s);
+    auto shorter = StringImpl::create("abcdef"_s);
+    auto different = StringImpl::create("abcrefg"_s);
 
     // Identity.
     ASSERT_TRUE(equalIgnoringASCIICase(a.ptr(), a.ptr()));
@@ -153,7 +142,7 @@
 
 TEST(WTF, StringImplEqualIgnoringASCIICaseWithNull)
 {
-    auto reference = StringImpl::createFromLiteral("aBcDeFG"_s);
+    auto reference = StringImpl::create("aBcDeFG"_s);
     StringImpl* nullStringImpl = nullptr;
     ASSERT_FALSE(equalIgnoringASCIICase(nullStringImpl, reference.ptr()));
     ASSERT_FALSE(equalIgnoringASCIICase(reference.ptr(), nullStringImpl));
@@ -209,26 +198,26 @@
     EXPECT_EQ(static_cast<size_t>(notFound), referenceB->findIgnoringASCIICase(referenceA.ptr()));
 
     // Find the prefix.
-    EXPECT_EQ(static_cast<size_t>(0), referenceA->findIgnoringASCIICase(StringImpl::createFromLiteral("a"_s).ptr()));
+    EXPECT_EQ(static_cast<size_t>(0), referenceA->findIgnoringASCIICase(StringImpl::create("a"_s).ptr()));
     EXPECT_EQ(static_cast<size_t>(0), referenceA->findIgnoringASCIICase(stringFromUTF8("abcé").ptr()));
-    EXPECT_EQ(static_cast<size_t>(0), referenceA->findIgnoringASCIICase(StringImpl::createFromLiteral("A"_s).ptr()));
+    EXPECT_EQ(static_cast<size_t>(0), referenceA->findIgnoringASCIICase(StringImpl::create("A"_s).ptr()));
     EXPECT_EQ(static_cast<size_t>(0), referenceA->findIgnoringASCIICase(stringFromUTF8("ABCé").ptr()));
-    EXPECT_EQ(static_cast<size_t>(0), referenceB->findIgnoringASCIICase(StringImpl::createFromLiteral("a"_s).ptr()));
+    EXPECT_EQ(static_cast<size_t>(0), referenceB->findIgnoringASCIICase(StringImpl::create("a"_s).ptr()));
     EXPECT_EQ(static_cast<size_t>(0), referenceB->findIgnoringASCIICase(stringFromUTF8("abcÉ").ptr()));
-    EXPECT_EQ(static_cast<size_t>(0), referenceB->findIgnoringASCIICase(StringImpl::createFromLiteral("A"_s).ptr()));
+    EXPECT_EQ(static_cast<size_t>(0), referenceB->findIgnoringASCIICase(StringImpl::create("A"_s).ptr()));
     EXPECT_EQ(static_cast<size_t>(0), referenceB->findIgnoringASCIICase(stringFromUTF8("ABCÉ").ptr()));
 
     // Not a prefix.
-    EXPECT_EQ(static_cast<size_t>(WTF::notFound), referenceA->findIgnoringASCIICase(StringImpl::createFromLiteral("x"_s).ptr()));
+    EXPECT_EQ(static_cast<size_t>(WTF::notFound), referenceA->findIgnoringASCIICase(StringImpl::create("x"_s).ptr()));
     EXPECT_EQ(static_cast<size_t>(WTF::notFound), referenceA->findIgnoringASCIICase(stringFromUTF8("accé").ptr()));
     EXPECT_EQ(static_cast<size_t>(WTF::notFound), referenceA->findIgnoringASCIICase(stringFromUTF8("abcÉ").ptr()));
-    EXPECT_EQ(static_cast<size_t>(WTF::notFound), referenceA->findIgnoringASCIICase(StringImpl::createFromLiteral("X"_s).ptr()));
+    EXPECT_EQ(static_cast<size_t>(WTF::notFound), referenceA->findIgnoringASCIICase(StringImpl::create("X"_s).ptr()));
     EXPECT_EQ(static_cast<size_t>(WTF::notFound), referenceA->findIgnoringASCIICase(stringFromUTF8("ABDé").ptr()));
     EXPECT_EQ(static_cast<size_t>(WTF::notFound), referenceA->findIgnoringASCIICase(stringFromUTF8("ABCÉ").ptr()));
-    EXPECT_EQ(static_cast<size_t>(WTF::notFound), referenceB->findIgnoringASCIICase(StringImpl::createFromLiteral("y"_s).ptr()));
+    EXPECT_EQ(static_cast<size_t>(WTF::notFound), referenceB->findIgnoringASCIICase(StringImpl::create("y"_s).ptr()));
     EXPECT_EQ(static_cast<size_t>(WTF::notFound), referenceB->findIgnoringASCIICase(stringFromUTF8("accÉ").ptr()));
     EXPECT_EQ(static_cast<size_t>(WTF::notFound), referenceB->findIgnoringASCIICase(stringFromUTF8("abcé").ptr()));
-    EXPECT_EQ(static_cast<size_t>(WTF::notFound), referenceB->findIgnoringASCIICase(StringImpl::createFromLiteral("Y"_s).ptr()));
+    EXPECT_EQ(static_cast<size_t>(WTF::notFound), referenceB->findIgnoringASCIICase(StringImpl::create("Y"_s).ptr()));
     EXPECT_EQ(static_cast<size_t>(WTF::notFound), referenceB->findIgnoringASCIICase(stringFromUTF8("ABdÉ").ptr()));
     EXPECT_EQ(static_cast<size_t>(WTF::notFound), referenceB->findIgnoringASCIICase(stringFromUTF8("ABCé").ptr()));
 
@@ -275,32 +264,32 @@
     EXPECT_EQ(static_cast<size_t>(WTF::notFound), referenceB->findIgnoringASCIICase(stringFromUTF8("z").ptr()));
 
     // Find the suffix.
-    EXPECT_EQ(static_cast<size_t>(6), referenceA->findIgnoringASCIICase(StringImpl::createFromLiteral("g"_s).ptr()));
+    EXPECT_EQ(static_cast<size_t>(6), referenceA->findIgnoringASCIICase(StringImpl::create("g"_s).ptr()));
     EXPECT_EQ(static_cast<size_t>(4), referenceA->findIgnoringASCIICase(stringFromUTF8("efg").ptr()));
     EXPECT_EQ(static_cast<size_t>(3), referenceA->findIgnoringASCIICase(stringFromUTF8("éefg").ptr()));
-    EXPECT_EQ(static_cast<size_t>(6), referenceA->findIgnoringASCIICase(StringImpl::createFromLiteral("G"_s).ptr()));
+    EXPECT_EQ(static_cast<size_t>(6), referenceA->findIgnoringASCIICase(StringImpl::create("G"_s).ptr()));
     EXPECT_EQ(static_cast<size_t>(4), referenceA->findIgnoringASCIICase(stringFromUTF8("EFG").ptr()));
     EXPECT_EQ(static_cast<size_t>(3), referenceA->findIgnoringASCIICase(stringFromUTF8("éEFG").ptr()));
 
-    EXPECT_EQ(static_cast<size_t>(6), referenceB->findIgnoringASCIICase(StringImpl::createFromLiteral("g"_s).ptr()));
+    EXPECT_EQ(static_cast<size_t>(6), referenceB->findIgnoringASCIICase(StringImpl::create("g"_s).ptr()));
     EXPECT_EQ(static_cast<size_t>(4), referenceB->findIgnoringASCIICase(stringFromUTF8("efg").ptr()));
     EXPECT_EQ(static_cast<size_t>(3), referenceB->findIgnoringASCIICase(stringFromUTF8("Éefg").ptr()));
-    EXPECT_EQ(static_cast<size_t>(6), referenceB->findIgnoringASCIICase(StringImpl::createFromLiteral("G"_s).ptr()));
+    EXPECT_EQ(static_cast<size_t>(6), referenceB->findIgnoringASCIICase(StringImpl::create("G"_s).ptr()));
     EXPECT_EQ(static_cast<size_t>(4), referenceB->findIgnoringASCIICase(stringFromUTF8("EFG").ptr()));
     EXPECT_EQ(static_cast<size_t>(3), referenceB->findIgnoringASCIICase(stringFromUTF8("ÉEFG").ptr()));
 
     // Not a suffix.
-    EXPECT_EQ(static_cast<size_t>(WTF::notFound), referenceA->findIgnoringASCIICase(StringImpl::createFromLiteral("X"_s).ptr()));
+    EXPECT_EQ(static_cast<size_t>(WTF::notFound), referenceA->findIgnoringASCIICase(StringImpl::create("X"_s).ptr()));
     EXPECT_EQ(static_cast<size_t>(WTF::notFound), referenceA->findIgnoringASCIICase(stringFromUTF8("edg").ptr()));
     EXPECT_EQ(static_cast<size_t>(WTF::notFound), referenceA->findIgnoringASCIICase(stringFromUTF8("Éefg").ptr()));
-    EXPECT_EQ(static_cast<size_t>(WTF::notFound), referenceA->findIgnoringASCIICase(StringImpl::createFromLiteral("w"_s).ptr()));
+    EXPECT_EQ(static_cast<size_t>(WTF::notFound), referenceA->findIgnoringASCIICase(StringImpl::create("w"_s).ptr()));
     EXPECT_EQ(static_cast<size_t>(WTF::notFound), referenceA->findIgnoringASCIICase(stringFromUTF8("dFG").ptr()));
     EXPECT_EQ(static_cast<size_t>(WTF::notFound), referenceA->findIgnoringASCIICase(stringFromUTF8("ÉEFG").ptr()));
 
-    EXPECT_EQ(static_cast<size_t>(WTF::notFound), referenceB->findIgnoringASCIICase(StringImpl::createFromLiteral("Z"_s).ptr()));
+    EXPECT_EQ(static_cast<size_t>(WTF::notFound), referenceB->findIgnoringASCIICase(StringImpl::create("Z"_s).ptr()));
     EXPECT_EQ(static_cast<size_t>(WTF::notFound), referenceB->findIgnoringASCIICase(stringFromUTF8("ffg").ptr()));
     EXPECT_EQ(static_cast<size_t>(WTF::notFound), referenceB->findIgnoringASCIICase(stringFromUTF8("éefg").ptr()));
-    EXPECT_EQ(static_cast<size_t>(WTF::notFound), referenceB->findIgnoringASCIICase(StringImpl::createFromLiteral("r"_s).ptr()));
+    EXPECT_EQ(static_cast<size_t>(WTF::notFound), referenceB->findIgnoringASCIICase(StringImpl::create("r"_s).ptr()));
     EXPECT_EQ(static_cast<size_t>(WTF::notFound), referenceB->findIgnoringASCIICase(stringFromUTF8("EgG").ptr()));
     EXPECT_EQ(static_cast<size_t>(WTF::notFound), referenceB->findIgnoringASCIICase(stringFromUTF8("éEFG").ptr()));
 }
@@ -375,17 +364,17 @@
     ASSERT_TRUE(referenceEquivalent->startsWithIgnoringASCIICase(*referenceEquivalent.ptr()));
 
     // Proper prefixes.
-    auto aLower = StringImpl::createFromLiteral("a"_s);
+    auto aLower = StringImpl::create("a"_s);
     ASSERT_TRUE(reference->startsWithIgnoringASCIICase(aLower.ptr()));
     ASSERT_TRUE(reference->startsWithIgnoringASCIICase(*aLower.ptr()));
-    auto aUpper = StringImpl::createFromLiteral("A"_s);
+    auto aUpper = StringImpl::create("A"_s);
     ASSERT_TRUE(reference->startsWithIgnoringASCIICase(aUpper.ptr()));
     ASSERT_TRUE(reference->startsWithIgnoringASCIICase(*aUpper.ptr()));
 
-    auto abcLower = StringImpl::createFromLiteral("abc"_s);
+    auto abcLower = StringImpl::create("abc"_s);
     ASSERT_TRUE(reference->startsWithIgnoringASCIICase(abcLower.ptr()));
     ASSERT_TRUE(reference->startsWithIgnoringASCIICase(*abcLower.ptr()));
-    auto abcUpper = StringImpl::createFromLiteral("ABC"_s);
+    auto abcUpper = StringImpl::create("ABC"_s);
     ASSERT_TRUE(reference->startsWithIgnoringASCIICase(abcUpper.ptr()));
     ASSERT_TRUE(reference->startsWithIgnoringASCIICase(*abcUpper.ptr()));
 
@@ -414,7 +403,7 @@
 
 TEST(WTF, StringImplStartsWithIgnoringASCIICaseWithNull)
 {
-    auto reference = StringImpl::createFromLiteral("aBcDeFG"_s);
+    auto reference = StringImpl::create("aBcDeFG"_s);
     ASSERT_FALSE(reference->startsWithIgnoringASCIICase(StringView { }));
 
     auto empty = StringImpl::create(reinterpret_cast<const LChar*>(""), 0);
@@ -423,7 +412,7 @@
 
 TEST(WTF, StringImplStartsWithIgnoringASCIICaseWithEmpty)
 {
-    auto reference = StringImpl::createFromLiteral("aBcDeFG"_s);
+    auto reference = StringImpl::create("aBcDeFG"_s);
     auto empty = StringImpl::create(reinterpret_cast<const LChar*>(""), 0);
     ASSERT_TRUE(reference->startsWithIgnoringASCIICase(empty.ptr()));
     ASSERT_TRUE(reference->startsWithIgnoringASCIICase(*empty.ptr()));
@@ -464,17 +453,17 @@
     ASSERT_TRUE(referenceEquivalent->endsWithIgnoringASCIICase(*referenceEquivalent.ptr()));
 
     // Proper suffixes.
-    auto aLower = StringImpl::createFromLiteral("a"_s);
+    auto aLower = StringImpl::create("a"_s);
     ASSERT_TRUE(reference->endsWithIgnoringASCIICase(aLower.ptr()));
     ASSERT_TRUE(reference->endsWithIgnoringASCIICase(*aLower.ptr()));
-    auto aUpper = StringImpl::createFromLiteral("a"_s);
+    auto aUpper = StringImpl::create("a"_s);
     ASSERT_TRUE(reference->endsWithIgnoringASCIICase(aUpper.ptr()));
     ASSERT_TRUE(reference->endsWithIgnoringASCIICase(*aUpper.ptr()));
 
-    auto abcLower = StringImpl::createFromLiteral("cba"_s);
+    auto abcLower = StringImpl::create("cba"_s);
     ASSERT_TRUE(reference->endsWithIgnoringASCIICase(abcLower.ptr()));
     ASSERT_TRUE(reference->endsWithIgnoringASCIICase(*abcLower.ptr()));
-    auto abcUpper = StringImpl::createFromLiteral("CBA"_s);
+    auto abcUpper = StringImpl::create("CBA"_s);
     ASSERT_TRUE(reference->endsWithIgnoringASCIICase(abcUpper.ptr()));
     ASSERT_TRUE(reference->endsWithIgnoringASCIICase(*abcUpper.ptr()));
 
@@ -503,7 +492,7 @@
 
 TEST(WTF, StringImplEndsWithIgnoringASCIICaseWithNull)
 {
-    auto reference = StringImpl::createFromLiteral("aBcDeFG"_s);
+    auto reference = StringImpl::create("aBcDeFG"_s);
     ASSERT_FALSE(reference->endsWithIgnoringASCIICase(StringView { }));
 
     auto empty = StringImpl::create(reinterpret_cast<const LChar*>(""), 0);
@@ -512,7 +501,7 @@
 
 TEST(WTF, StringImplEndsWithIgnoringASCIICaseWithEmpty)
 {
-    auto reference = StringImpl::createFromLiteral("aBcDeFG"_s);
+    auto reference = StringImpl::create("aBcDeFG"_s);
     auto empty = StringImpl::create(reinterpret_cast<const LChar*>(""), 0);
     ASSERT_TRUE(reference->endsWithIgnoringASCIICase(empty.ptr()));
     ASSERT_TRUE(reference->endsWithIgnoringASCIICase(*empty.ptr()));

Modified: trunk/Tools/TestWebKitAPI/Tests/WTF/StringView.cpp (293762 => 293763)


--- trunk/Tools/TestWebKitAPI/Tests/WTF/StringView.cpp	2022-05-04 06:25:05 UTC (rev 293762)
+++ trunk/Tools/TestWebKitAPI/Tests/WTF/StringView.cpp	2022-05-04 07:02:57 UTC (rev 293763)
@@ -335,13 +335,13 @@
 
 TEST(WTF, StringViewEqualIgnoringASCIICaseBasic)
 {
-    RefPtr<StringImpl> a = StringImpl::createFromLiteral("aBcDeFG"_s);
-    RefPtr<StringImpl> b = StringImpl::createFromLiteral("ABCDEFG"_s);
-    RefPtr<StringImpl> c = StringImpl::createFromLiteral("abcdefg"_s);
+    RefPtr<StringImpl> a = StringImpl::create("aBcDeFG"_s);
+    RefPtr<StringImpl> b = StringImpl::create("ABCDEFG"_s);
+    RefPtr<StringImpl> c = StringImpl::create("abcdefg"_s);
     constexpr auto d = "aBcDeFG"_s;
     RefPtr<StringImpl> empty = StringImpl::create(reinterpret_cast<const LChar*>(""), 0);
-    RefPtr<StringImpl> shorter = StringImpl::createFromLiteral("abcdef"_s);
-    RefPtr<StringImpl> different = StringImpl::createFromLiteral("abcrefg"_s);
+    RefPtr<StringImpl> shorter = StringImpl::create("abcdef"_s);
+    RefPtr<StringImpl> different = StringImpl::create("abcrefg"_s);
 
     StringView stringViewA(*a.get());
     StringView stringViewB(*b.get());
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to