Title: [275002] trunk/Source/WTF
Revision
275002
Author
[email protected]
Date
2021-03-24 19:31:29 -0700 (Wed, 24 Mar 2021)

Log Message

Use StaticStringImpl instead of StringImpl::createStaticStringImpl if it is not dynamic string content
https://bugs.webkit.org/show_bug.cgi?id=223714

Reviewed by Saam Barati.

We should just use StaticStringImpl instead of StringImpl::createStaticStringImpl if the string content is
not dynamically allocated one. Keep in mind that this URL code is strongly assuming that internal StringImpl
is static so that this string (and URL) can be used in multiple threads. And StaticStringImpl meets this requirement.

* wtf/URL.cpp:
(WTF::aboutBlankURL):
(WTF::aboutSrcDocURL):

Modified Paths

Diff

Modified: trunk/Source/WTF/ChangeLog (275001 => 275002)


--- trunk/Source/WTF/ChangeLog	2021-03-25 02:20:28 UTC (rev 275001)
+++ trunk/Source/WTF/ChangeLog	2021-03-25 02:31:29 UTC (rev 275002)
@@ -1,5 +1,20 @@
 2021-03-24  Yusuke Suzuki  <[email protected]>
 
+        Use StaticStringImpl instead of StringImpl::createStaticStringImpl if it is not dynamic string content
+        https://bugs.webkit.org/show_bug.cgi?id=223714
+
+        Reviewed by Saam Barati.
+
+        We should just use StaticStringImpl instead of StringImpl::createStaticStringImpl if the string content is
+        not dynamically allocated one. Keep in mind that this URL code is strongly assuming that internal StringImpl
+        is static so that this string (and URL) can be used in multiple threads. And StaticStringImpl meets this requirement.
+
+        * wtf/URL.cpp:
+        (WTF::aboutBlankURL):
+        (WTF::aboutSrcDocURL):
+
+2021-03-24  Yusuke Suzuki  <[email protected]>
+
         All string resources from UserAgentStyleSheets / UserAgentScripts should be used as non-copying StringImpl
         https://bugs.webkit.org/show_bug.cgi?id=223685
 

Modified: trunk/Source/WTF/wtf/URL.cpp (275001 => 275002)


--- trunk/Source/WTF/wtf/URL.cpp	2021-03-25 02:20:28 UTC (rev 275001)
+++ trunk/Source/WTF/wtf/URL.cpp	2021-03-25 02:31:29 UTC (rev 275002)
@@ -854,24 +854,25 @@
         && (url[4] == ':' || (isASCIIAlphaCaselessEqual(url[4], 's') && length >= 6 && url[5] == ':'));
 }
 
+
+static StaticStringImpl aboutBlankString { "about:blank" };
 const URL& aboutBlankURL()
 {
     static LazyNeverDestroyed<URL> staticBlankURL;
     static std::once_flag onceFlag;
     std::call_once(onceFlag, [&] {
-        static constexpr const char* aboutBlank = "about:blank";
-        staticBlankURL.construct(URL(), StringImpl::createStaticStringImpl(aboutBlank, strlen(aboutBlank)));
+        staticBlankURL.construct(URL(), &aboutBlankString);
     });
     return staticBlankURL;
 }
 
+static StaticStringImpl aboutSrcDocString { "about:srcdoc" };
 const URL& aboutSrcDocURL()
 {
     static LazyNeverDestroyed<URL> staticSrcDocURL;
     static std::once_flag onceFlag;
     std::call_once(onceFlag, [&] {
-        static constexpr const char* aboutSrcDoc = "about:srcdoc";
-        staticSrcDocURL.construct(URL(), StringImpl::createStaticStringImpl(aboutSrcDoc, strlen(aboutSrcDoc)));
+        staticSrcDocURL.construct(URL(), &aboutSrcDocString);
     });
     return staticSrcDocURL;
 }
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to