Title: [291787] trunk
Revision
291787
Author
cdu...@apple.com
Date
2022-03-23 23:27:16 -0700 (Wed, 23 Mar 2022)

Log Message

Inline String(ASCIILiteral) constructor so the compiler can optimize out strlen()
https://bugs.webkit.org/show_bug.cgi?id=238162

Reviewed by Geoffrey Garen.

I have verified using a profiler that strlen() is no longer called under String::String(WTF::ASCIILiteral)
or StringImpl::createFromLiteral(WTF::ASCIILiteral) when running Speedometer.

* wtf/text/StringImpl.cpp:
* wtf/text/StringImpl.h:
(WTF::StringImpl::createFromLiteral):
* wtf/text/WTFString.cpp:
* wtf/text/WTFString.h:
(WTF::String::String):

Modified Paths

Diff

Modified: trunk/Source/WTF/ChangeLog (291786 => 291787)


--- trunk/Source/WTF/ChangeLog	2022-03-24 06:25:20 UTC (rev 291786)
+++ trunk/Source/WTF/ChangeLog	2022-03-24 06:27:16 UTC (rev 291787)
@@ -1,3 +1,20 @@
+2022-03-23  Chris Dumez  <cdu...@apple.com>
+
+        Inline String(ASCIILiteral) constructor so the compiler can optimize out strlen()
+        https://bugs.webkit.org/show_bug.cgi?id=238162
+
+        Reviewed by Geoffrey Garen.
+
+        I have verified using a profiler that strlen() is no longer called under String::String(WTF::ASCIILiteral)
+        or StringImpl::createFromLiteral(WTF::ASCIILiteral) when running Speedometer.
+
+        * wtf/text/StringImpl.cpp:
+        * wtf/text/StringImpl.h:
+        (WTF::StringImpl::createFromLiteral):
+        * wtf/text/WTFString.cpp:
+        * wtf/text/WTFString.h:
+        (WTF::String::String):
+
 2022-03-23  Alex Christensen  <achristen...@webkit.org>
 
         Add off-by-default experimental feature for app store attribution

Modified: trunk/Source/WTF/wtf/text/StringImpl.cpp (291786 => 291787)


--- trunk/Source/WTF/wtf/text/StringImpl.cpp	2022-03-24 06:25:20 UTC (rev 291786)
+++ trunk/Source/WTF/wtf/text/StringImpl.cpp	2022-03-24 06:27:16 UTC (rev 291787)
@@ -163,11 +163,6 @@
     return createFromLiteral(characters, strlen(characters));
 }
 
-Ref<StringImpl> StringImpl::createFromLiteral(ASCIILiteral literal)
-{
-    return createFromLiteral(literal.characters(), literal.length());
-}
-
 Ref<StringImpl> StringImpl::createWithoutCopying(const UChar* characters, unsigned length)
 {
     if (!length)

Modified: trunk/Source/WTF/wtf/text/StringImpl.h (291786 => 291787)


--- trunk/Source/WTF/wtf/text/StringImpl.h	2022-03-24 06:25:20 UTC (rev 291786)
+++ trunk/Source/WTF/wtf/text/StringImpl.h	2022-03-24 06:27:16 UTC (rev 291787)
@@ -245,12 +245,10 @@
 
     static Ref<StringImpl> createSubstringSharingImpl(StringImpl&, unsigned offset, unsigned length);
 
-    template<unsigned characterCount> static Ref<StringImpl> createFromLiteral(const char (&)[characterCount]);
-
     // 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*);
-    WTF_EXPORT_PRIVATE static Ref<StringImpl> createFromLiteral(ASCIILiteral);
+    static Ref<StringImpl> createFromLiteral(ASCIILiteral);
 
     WTF_EXPORT_PRIVATE static Ref<StringImpl> createWithoutCopying(const UChar*, unsigned length);
     WTF_EXPORT_PRIVATE static Ref<StringImpl> createWithoutCopying(const LChar*, unsigned length);
@@ -982,12 +980,9 @@
     return adoptRef(*new (NotNull, stringImpl) StringImpl(rep.m_data16 + offset, length, *ownerRep));
 }
 
-template<unsigned characterCount> ALWAYS_INLINE Ref<StringImpl> StringImpl::createFromLiteral(const char (&characters)[characterCount])
+inline Ref<StringImpl> StringImpl::createFromLiteral(ASCIILiteral literal)
 {
-    COMPILE_ASSERT(characterCount > 1, StringImplFromLiteralNotEmpty);
-    COMPILE_ASSERT((characterCount - 1 <= ((unsigned(~0) - sizeof(StringImpl)) / sizeof(LChar))), StringImplFromLiteralCannotOverflow);
-
-    return createWithoutCopying(reinterpret_cast<const LChar*>(characters), characterCount - 1);
+    return createFromLiteral(literal.characters(), literal.length());
 }
 
 template<typename CharacterType> ALWAYS_INLINE RefPtr<StringImpl> StringImpl::tryCreateUninitialized(unsigned length, CharacterType*& output)

Modified: trunk/Source/WTF/wtf/text/WTFString.cpp (291786 => 291787)


--- trunk/Source/WTF/wtf/text/WTFString.cpp	2022-03-24 06:25:20 UTC (rev 291786)
+++ trunk/Source/WTF/wtf/text/WTFString.cpp	2022-03-24 06:27:16 UTC (rev 291787)
@@ -79,11 +79,6 @@
         m_impl = StringImpl::create(reinterpret_cast<const LChar*>(nullTerminatedString));
 }
 
-String::String(ASCIILiteral characters)
-    : m_impl(characters.isNull() ? nullptr : RefPtr<StringImpl> { StringImpl::createFromLiteral(characters) })
-{
-}
-
 void String::append(const String& otherString)
 {
     // FIXME: This is extremely inefficient. So much so that we might want to take this out of String's API.

Modified: trunk/Source/WTF/wtf/text/WTFString.h (291786 => 291787)


--- trunk/Source/WTF/wtf/text/WTFString.h	2022-03-24 06:25:20 UTC (rev 291786)
+++ trunk/Source/WTF/wtf/text/WTFString.h	2022-03-24 06:27:16 UTC (rev 291787)
@@ -99,11 +99,6 @@
     // Construct a string from a constant string literal.
     WTF_EXPORT_PRIVATE String(ASCIILiteral);
 
-    // Construct a string from a constant string literal.
-    // This is the "big" version: puts the length in the function call and generates bigger code.
-    enum ConstructFromLiteralTag { ConstructFromLiteral };
-    template<unsigned characterCount> String(const char (&characters)[characterCount], ConstructFromLiteralTag) : m_impl(StringImpl::createFromLiteral<characterCount>(characters)) { }
-
     String(const String&) = default;
     String(String&&) = default;
     String& operator=(const String&) = default;
@@ -471,6 +466,11 @@
 {
 }
 
+inline String::String(ASCIILiteral characters)
+    : m_impl(characters.isNull() ? nullptr : RefPtr<StringImpl> { StringImpl::createFromLiteral(characters) })
+{
+}
+
 template<size_t inlineCapacity, typename OverflowHandler> String::String(const Vector<UChar, inlineCapacity, OverflowHandler>& vector)
     : m_impl(vector.size() ? StringImpl::create(vector.data(), vector.size()) : Ref<StringImpl> { *StringImpl::empty() })
 {

Modified: trunk/Source/WebCore/platform/graphics/win/FontCacheWin.cpp (291786 => 291787)


--- trunk/Source/WebCore/platform/graphics/win/FontCacheWin.cpp	2022-03-24 06:25:20 UTC (rev 291786)
+++ trunk/Source/WebCore/platform/graphics/win/FontCacheWin.cpp	2022-03-24 06:27:16 UTC (rev 291787)
@@ -378,11 +378,11 @@
         // Sorted by most to least glyphs according to http://en.wikipedia.org/wiki/Unicode_typefaces
         // Start with Times New Roman also since it is the default if the user doesn't change prefs.
         static NeverDestroyed<const String> fallbackFonts[] = {
-            String("Times New Roman", String::ConstructFromLiteral),
-            String("Microsoft Sans Serif", String::ConstructFromLiteral),
-            String("Tahoma", String::ConstructFromLiteral),
-            String("Lucida Sans Unicode", String::ConstructFromLiteral),
-            String("Arial", String::ConstructFromLiteral)
+            "Times New Roman"_str,
+            "Microsoft Sans Serif"_str,
+            "Tahoma"_str,
+            "Lucida Sans Unicode"_str,
+            "Arial"_str
         };
         for (size_t i = 0; i < WTF_ARRAY_LENGTH(fallbackFonts); ++i) {
             if (fontForFamily(fontDescription, fallbackFonts[i])) {

Modified: trunk/Tools/TestWebKitAPI/Tests/WTF/FileSystem.cpp (291786 => 291787)


--- trunk/Tools/TestWebKitAPI/Tests/WTF/FileSystem.cpp	2022-03-24 06:25:20 UTC (rev 291786)
+++ trunk/Tools/TestWebKitAPI/Tests/WTF/FileSystem.cpp	2022-03-24 06:27:16 UTC (rev 291787)
@@ -840,7 +840,7 @@
 TEST_F(FileSystemTest, makeSafeToUseMemoryMapForPath)
 {
     EXPECT_TRUE(FileSystem::makeSafeToUseMemoryMapForPath(tempFilePath()));
-    auto result = FileSystem::makeSafeToUseMemoryMapForPath(String("Thisisnotarealfile", String::ConstructFromLiteral));
+    auto result = FileSystem::makeSafeToUseMemoryMapForPath("Thisisnotarealfile"_str);
 #if PLATFORM(IOS_FAMILY) && !PLATFORM(IOS_FAMILY_SIMULATOR)
     // NSFileProtectionKey only actually means anything on-device.
     EXPECT_FALSE(result);

Modified: trunk/Tools/TestWebKitAPI/Tests/WTF/StringImpl.cpp (291786 => 291787)


--- trunk/Tools/TestWebKitAPI/Tests/WTF/StringImpl.cpp	2022-03-24 06:25:20 UTC (rev 291786)
+++ trunk/Tools/TestWebKitAPI/Tests/WTF/StringImpl.cpp	2022-03-24 06:27:16 UTC (rev 291787)
@@ -36,7 +36,7 @@
 TEST(WTF, StringImplCreationFromLiteral)
 {
     // Constructor using the template to determine the size.
-    auto stringWithTemplate = StringImpl::createFromLiteral("Template Literal");
+    auto stringWithTemplate = StringImpl::createFromLiteral("Template Literal"_s);
     ASSERT_EQ(strlen("Template Literal"), stringWithTemplate->length());
     ASSERT_TRUE(equal(stringWithTemplate.get(), "Template Literal"));
     ASSERT_TRUE(stringWithTemplate->is8Bit());
@@ -71,7 +71,7 @@
 
 TEST(WTF, StringImplReplaceWithLiteral)
 {
-    auto testStringImpl = StringImpl::createFromLiteral("1224");
+    auto testStringImpl = StringImpl::createFromLiteral("1224"_s);
     ASSERT_TRUE(testStringImpl->is8Bit());
 
     // Cases for 8Bit source.
@@ -78,7 +78,7 @@
     testStringImpl = testStringImpl->replace('2', "", 0);
     ASSERT_TRUE(equal(testStringImpl.get(), "14"));
 
-    testStringImpl = StringImpl::createFromLiteral("1224");
+    testStringImpl = StringImpl::createFromLiteral("1224"_s);
     ASSERT_TRUE(testStringImpl->is8Bit());
 
     testStringImpl = testStringImpl->replace('3', "NotFound", 8);
@@ -87,7 +87,7 @@
     testStringImpl = testStringImpl->replace('2', "3", 1);
     ASSERT_TRUE(equal(testStringImpl.get(), "1334"));
 
-    testStringImpl = StringImpl::createFromLiteral("1224");
+    testStringImpl = StringImpl::createFromLiteral("1224"_s);
     ASSERT_TRUE(testStringImpl->is8Bit());
     testStringImpl = testStringImpl->replace('2', "555", 3);
     ASSERT_TRUE(equal(testStringImpl.get(), "15555554"));
@@ -115,13 +115,13 @@
 
 TEST(WTF, StringImplEqualIgnoringASCIICaseBasic)
 {
-    auto a = StringImpl::createFromLiteral("aBcDeFG");
-    auto b = StringImpl::createFromLiteral("ABCDEFG");
-    auto c = StringImpl::createFromLiteral("abcdefg");
+    auto a = StringImpl::createFromLiteral("aBcDeFG"_s);
+    auto b = StringImpl::createFromLiteral("ABCDEFG"_s);
+    auto c = StringImpl::createFromLiteral("abcdefg"_s);
     const char d[] = "aBcDeFG";
     auto empty = StringImpl::create(reinterpret_cast<const LChar*>(""));
-    auto shorter = StringImpl::createFromLiteral("abcdef");
-    auto different = StringImpl::createFromLiteral("abcrefg");
+    auto shorter = StringImpl::createFromLiteral("abcdef"_s);
+    auto different = StringImpl::createFromLiteral("abcrefg"_s);
 
     // Identity.
     ASSERT_TRUE(equalIgnoringASCIICase(a.ptr(), a.ptr()));
@@ -153,7 +153,7 @@
 
 TEST(WTF, StringImplEqualIgnoringASCIICaseWithNull)
 {
-    auto reference = StringImpl::createFromLiteral("aBcDeFG");
+    auto reference = StringImpl::createFromLiteral("aBcDeFG"_s);
     StringImpl* nullStringImpl = nullptr;
     ASSERT_FALSE(equalIgnoringASCIICase(nullStringImpl, reference.ptr()));
     ASSERT_FALSE(equalIgnoringASCIICase(reference.ptr(), nullStringImpl));
@@ -214,26 +214,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").ptr()));
+    EXPECT_EQ(static_cast<size_t>(0), referenceA->findIgnoringASCIICase(StringImpl::createFromLiteral("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").ptr()));
+    EXPECT_EQ(static_cast<size_t>(0), referenceA->findIgnoringASCIICase(StringImpl::createFromLiteral("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").ptr()));
+    EXPECT_EQ(static_cast<size_t>(0), referenceB->findIgnoringASCIICase(StringImpl::createFromLiteral("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").ptr()));
+    EXPECT_EQ(static_cast<size_t>(0), referenceB->findIgnoringASCIICase(StringImpl::createFromLiteral("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").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(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").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(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").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(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").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(stringFromUTF8("ABdÉ").ptr()));
     EXPECT_EQ(static_cast<size_t>(WTF::notFound), referenceB->findIgnoringASCIICase(stringFromUTF8("ABCé").ptr()));
 
@@ -280,32 +280,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").ptr()));
+    EXPECT_EQ(static_cast<size_t>(6), referenceA->findIgnoringASCIICase(StringImpl::createFromLiteral("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").ptr()));
+    EXPECT_EQ(static_cast<size_t>(6), referenceA->findIgnoringASCIICase(StringImpl::createFromLiteral("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").ptr()));
+    EXPECT_EQ(static_cast<size_t>(6), referenceB->findIgnoringASCIICase(StringImpl::createFromLiteral("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").ptr()));
+    EXPECT_EQ(static_cast<size_t>(6), referenceB->findIgnoringASCIICase(StringImpl::createFromLiteral("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").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(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").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(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").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(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").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(stringFromUTF8("EgG").ptr()));
     EXPECT_EQ(static_cast<size_t>(WTF::notFound), referenceB->findIgnoringASCIICase(stringFromUTF8("éEFG").ptr()));
 }
@@ -380,17 +380,17 @@
     ASSERT_TRUE(referenceEquivalent->startsWithIgnoringASCIICase(*referenceEquivalent.ptr()));
 
     // Proper prefixes.
-    auto aLower = StringImpl::createFromLiteral("a");
+    auto aLower = StringImpl::createFromLiteral("a"_s);
     ASSERT_TRUE(reference->startsWithIgnoringASCIICase(aLower.ptr()));
     ASSERT_TRUE(reference->startsWithIgnoringASCIICase(*aLower.ptr()));
-    auto aUpper = StringImpl::createFromLiteral("A");
+    auto aUpper = StringImpl::createFromLiteral("A"_s);
     ASSERT_TRUE(reference->startsWithIgnoringASCIICase(aUpper.ptr()));
     ASSERT_TRUE(reference->startsWithIgnoringASCIICase(*aUpper.ptr()));
 
-    auto abcLower = StringImpl::createFromLiteral("abc");
+    auto abcLower = StringImpl::createFromLiteral("abc"_s);
     ASSERT_TRUE(reference->startsWithIgnoringASCIICase(abcLower.ptr()));
     ASSERT_TRUE(reference->startsWithIgnoringASCIICase(*abcLower.ptr()));
-    auto abcUpper = StringImpl::createFromLiteral("ABC");
+    auto abcUpper = StringImpl::createFromLiteral("ABC"_s);
     ASSERT_TRUE(reference->startsWithIgnoringASCIICase(abcUpper.ptr()));
     ASSERT_TRUE(reference->startsWithIgnoringASCIICase(*abcUpper.ptr()));
 
@@ -419,7 +419,7 @@
 
 TEST(WTF, StringImplStartsWithIgnoringASCIICaseWithNull)
 {
-    auto reference = StringImpl::createFromLiteral("aBcDeFG");
+    auto reference = StringImpl::createFromLiteral("aBcDeFG"_s);
     ASSERT_FALSE(reference->startsWithIgnoringASCIICase(nullptr));
 
     auto empty = StringImpl::create(reinterpret_cast<const LChar*>(""));
@@ -428,7 +428,7 @@
 
 TEST(WTF, StringImplStartsWithIgnoringASCIICaseWithEmpty)
 {
-    auto reference = StringImpl::createFromLiteral("aBcDeFG");
+    auto reference = StringImpl::createFromLiteral("aBcDeFG"_s);
     auto empty = StringImpl::create(reinterpret_cast<const LChar*>(""));
     ASSERT_TRUE(reference->startsWithIgnoringASCIICase(empty.ptr()));
     ASSERT_TRUE(reference->startsWithIgnoringASCIICase(*empty.ptr()));
@@ -469,17 +469,17 @@
     ASSERT_TRUE(referenceEquivalent->endsWithIgnoringASCIICase(*referenceEquivalent.ptr()));
 
     // Proper suffixes.
-    auto aLower = StringImpl::createFromLiteral("a");
+    auto aLower = StringImpl::createFromLiteral("a"_s);
     ASSERT_TRUE(reference->endsWithIgnoringASCIICase(aLower.ptr()));
     ASSERT_TRUE(reference->endsWithIgnoringASCIICase(*aLower.ptr()));
-    auto aUpper = StringImpl::createFromLiteral("a");
+    auto aUpper = StringImpl::createFromLiteral("a"_s);
     ASSERT_TRUE(reference->endsWithIgnoringASCIICase(aUpper.ptr()));
     ASSERT_TRUE(reference->endsWithIgnoringASCIICase(*aUpper.ptr()));
 
-    auto abcLower = StringImpl::createFromLiteral("cba");
+    auto abcLower = StringImpl::createFromLiteral("cba"_s);
     ASSERT_TRUE(reference->endsWithIgnoringASCIICase(abcLower.ptr()));
     ASSERT_TRUE(reference->endsWithIgnoringASCIICase(*abcLower.ptr()));
-    auto abcUpper = StringImpl::createFromLiteral("CBA");
+    auto abcUpper = StringImpl::createFromLiteral("CBA"_s);
     ASSERT_TRUE(reference->endsWithIgnoringASCIICase(abcUpper.ptr()));
     ASSERT_TRUE(reference->endsWithIgnoringASCIICase(*abcUpper.ptr()));
 
@@ -508,7 +508,7 @@
 
 TEST(WTF, StringImplEndsWithIgnoringASCIICaseWithNull)
 {
-    auto reference = StringImpl::createFromLiteral("aBcDeFG");
+    auto reference = StringImpl::createFromLiteral("aBcDeFG"_s);
     ASSERT_FALSE(reference->endsWithIgnoringASCIICase(nullptr));
 
     auto empty = StringImpl::create(reinterpret_cast<const LChar*>(""));
@@ -517,7 +517,7 @@
 
 TEST(WTF, StringImplEndsWithIgnoringASCIICaseWithEmpty)
 {
-    auto reference = StringImpl::createFromLiteral("aBcDeFG");
+    auto reference = StringImpl::createFromLiteral("aBcDeFG"_s);
     auto empty = StringImpl::create(reinterpret_cast<const LChar*>(""));
     ASSERT_TRUE(reference->endsWithIgnoringASCIICase(empty.ptr()));
     ASSERT_TRUE(reference->endsWithIgnoringASCIICase(*empty.ptr()));

Modified: trunk/Tools/TestWebKitAPI/Tests/WTF/StringView.cpp (291786 => 291787)


--- trunk/Tools/TestWebKitAPI/Tests/WTF/StringView.cpp	2022-03-24 06:25:20 UTC (rev 291786)
+++ trunk/Tools/TestWebKitAPI/Tests/WTF/StringView.cpp	2022-03-24 06:27:16 UTC (rev 291787)
@@ -335,13 +335,13 @@
 
 TEST(WTF, StringViewEqualIgnoringASCIICaseBasic)
 {
-    RefPtr<StringImpl> a = StringImpl::createFromLiteral("aBcDeFG");
-    RefPtr<StringImpl> b = StringImpl::createFromLiteral("ABCDEFG");
-    RefPtr<StringImpl> c = StringImpl::createFromLiteral("abcdefg");
+    RefPtr<StringImpl> a = StringImpl::createFromLiteral("aBcDeFG"_s);
+    RefPtr<StringImpl> b = StringImpl::createFromLiteral("ABCDEFG"_s);
+    RefPtr<StringImpl> c = StringImpl::createFromLiteral("abcdefg"_s);
     const char d[] = "aBcDeFG";
     RefPtr<StringImpl> empty = StringImpl::create(reinterpret_cast<const LChar*>(""));
-    RefPtr<StringImpl> shorter = StringImpl::createFromLiteral("abcdef");
-    RefPtr<StringImpl> different = StringImpl::createFromLiteral("abcrefg");
+    RefPtr<StringImpl> shorter = StringImpl::createFromLiteral("abcdef"_s);
+    RefPtr<StringImpl> different = StringImpl::createFromLiteral("abcrefg"_s);
 
     StringView stringViewA(*a.get());
     StringView stringViewB(*b.get());

Modified: trunk/Tools/TestWebKitAPI/Tests/WTF/WTFString.cpp (291786 => 291787)


--- trunk/Tools/TestWebKitAPI/Tests/WTF/WTFString.cpp	2022-03-24 06:25:20 UTC (rev 291786)
+++ trunk/Tools/TestWebKitAPI/Tests/WTF/WTFString.cpp	2022-03-24 06:27:16 UTC (rev 291787)
@@ -47,12 +47,6 @@
     EXPECT_EQ("String Literal", stringFromLiteral);
     EXPECT_TRUE(stringFromLiteral.is8Bit());
     EXPECT_EQ(String("String Literal"), stringFromLiteral);
-
-    String stringWithTemplate("Template Literal", String::ConstructFromLiteral);
-    EXPECT_EQ(strlen("Template Literal"), stringWithTemplate.length());
-    EXPECT_EQ("Template Literal", stringWithTemplate);
-    EXPECT_TRUE(stringWithTemplate.is8Bit());
-    EXPECT_EQ(String("Template Literal"), stringWithTemplate);
 }
 
 TEST(WTF, StringASCII)
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to