Define AtomString(ASCIILiteral) and use ASCIILiteral more to avoid memory allocation
https://bugs.webkit.org/show_bug.cgi?id=224125
Reviewed by Saam Barati.
Source/WebCore:
We apply "..."_s more. This avoids allocating of string storage when creating StringImpl.
* accessibility/AccessibilityObject.cpp:
(WebCore::initializeRoleMap):
* dom/ScriptElement.cpp:
(WebCore::isLegacySupportedJavaScriptLanguage):
* editing/EditorCommand.cpp:
(WebCore::createCommandMap):
* html/Autofill.cpp:
(WebCore::fieldNameMap):
* platform/LegacySchemeRegistry.cpp:
(WebCore::builtinLocalURLSchemes):
(WebCore::builtinSecureSchemes):
(WebCore::builtinSchemesWithUniqueOrigins):
(WebCore::builtinEmptyDocumentSchemes):
(WebCore::builtinCanDisplayOnlyIfCanRequestSchemes):
(WebCore::builtinCORSEnabledSchemes):
* platform/MIMETypeRegistry.cpp:
(WebCore::MIMETypeRegistry::systemPreviewMIMETypes):
* platform/graphics/FontCascade.cpp:
(WebCore::FontCascade::hasValidAverageCharWidth const):
* platform/graphics/HEVCUtilities.cpp:
(WebCore::codecStringForDoViCodecType):
(WebCore::profileIDForAlphabeticDoViProfile):
* platform/graphics/avfoundation/MediaPlayerPrivateAVFoundation.cpp:
(WebCore::MediaPlayerPrivateAVFoundation::staticMIMETypeList):
* platform/graphics/avfoundation/objc/AVAssetMIMETypeCache.mm:
(WebCore::AVAssetMIMETypeCache::staticContainerTypeList):
* platform/graphics/cg/ImageSourceCGWin.cpp:
(WebCore::preferredExtensionForImageType):
* svg/SVGTests.cpp:
(WebCore::supportedSVGFeatures):
Source/WTF:
Add AtomString(ASCIILiteral). ASCIILiteral ensures that storage is constant non-heap string by its type.
So we can just use it as a literal (not allocating a string storage).
* wtf/text/AtomString.h:
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@275457 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/Source/WebCore/platform/LegacySchemeRegistry.cpp b/Source/WebCore/platform/LegacySchemeRegistry.cpp
index b73d06a..c3f7560 100644
--- a/Source/WebCore/platform/LegacySchemeRegistry.cpp
+++ b/Source/WebCore/platform/LegacySchemeRegistry.cpp
@@ -113,9 +113,9 @@
{
ASSERT(schemeRegistryLock.isHeld());
static const auto schemes = makeNeverDestroyed(URLSchemesMap {
- "file",
+ "file"_s,
#if PLATFORM(COCOA)
- "applewebdata",
+ "applewebdata"_s,
#endif
});
return schemes;
@@ -139,12 +139,12 @@
{
ASSERT(schemeRegistryLock.isHeld());
static const auto schemes = makeNeverDestroyed(Vector<String> {
- "https",
- "about",
- "data",
- "wss",
+ "https"_s,
+ "about"_s,
+ "data"_s,
+ "wss"_s,
#if PLATFORM(GTK) || PLATFORM(WPE)
- "resource",
+ "resource"_s,
#endif
});
return schemes;
@@ -161,11 +161,11 @@
{
ASSERT(schemeRegistryLock.isHeld());
static const auto schemes = makeNeverDestroyed(Vector<String> {
- "about",
- "javascript",
+ "about"_s,
+ "javascript"_s,
// This is an intentional difference from the behavior the HTML specification calls for.
// See https://bugs.webkit.org/show_bug.cgi?id=11885
- "data",
+ "data"_s,
});
return schemes;
}
@@ -180,7 +180,7 @@
const Vector<String>& builtinEmptyDocumentSchemes()
{
ASSERT(isMainThread());
- static const auto schemes = makeNeverDestroyed(Vector<String> { "about" });
+ static const auto schemes = makeNeverDestroyed(Vector<String> { "about"_s });
return schemes;
}
@@ -201,7 +201,7 @@
const Vector<String>& builtinCanDisplayOnlyIfCanRequestSchemes()
{
ASSERT(schemeRegistryLock.isHeld());
- static const auto schemes = makeNeverDestroyed(Vector<String> { "blob" });
+ static const auto schemes = makeNeverDestroyed(Vector<String> { "blob"_s });
return schemes;
}
@@ -267,7 +267,7 @@
const Vector<String>& builtinCORSEnabledSchemes()
{
ASSERT(isMainThread());
- static const auto schemes = makeNeverDestroyed(Vector<String> { "http", "https" });
+ static const auto schemes = makeNeverDestroyed(Vector<String> { "http"_s, "https"_s });
return schemes;
}