Explorar o código

Everywhere: Convert known short-strings to the infallible String factory

For now, this is limited to strings that are 3 bytes or less. We can use
7 bytes on 64-bit platforms, but we do not yet assume 64-bit for Lagom
hosts (e.g. wasm).
Timothy Flynn %!s(int64=2) %!d(string=hai) anos
pai
achega
f1de4f8872

+ 1 - 1
Meta/Lagom/Tools/CodeGenerators/LibLocale/GenerateLocaleData.cpp

@@ -1377,7 +1377,7 @@ static LanguageMapping const* resolve_likely_subtag(LanguageID const& language_i
             if (!language_id.script.has_value())
             if (!language_id.script.has_value())
                 continue;
                 continue;
 
 
-            search_key.language = String::from_utf8("und"sv).release_value_but_fixme_should_propagate_errors();
+            search_key.language = String::from_utf8_short_string("und"sv);
             search_key.script = *language_id.script;
             search_key.script = *language_id.script;
             break;
             break;
 
 

+ 1 - 1
Userland/Libraries/LibCrypto/BigInt/UnsignedBigInteger.cpp

@@ -150,7 +150,7 @@ ErrorOr<String> UnsignedBigInteger::to_base(u16 N) const
 {
 {
     VERIFY(N <= 36);
     VERIFY(N <= 36);
     if (*this == UnsignedBigInteger { 0 })
     if (*this == UnsignedBigInteger { 0 })
-        return String::from_utf8("0"sv);
+        return String::from_utf8_short_string("0"sv);
 
 
     StringBuilder builder;
     StringBuilder builder;
     UnsignedBigInteger temp(*this);
     UnsignedBigInteger temp(*this);

+ 1 - 1
Userland/Libraries/LibGL/Shaders/Program.cpp

@@ -50,7 +50,7 @@ ErrorOr<void> Program::attach_shader(Shader& shader)
 
 
 ErrorOr<void> Program::link(GPU::Device& device)
 ErrorOr<void> Program::link(GPU::Device& device)
 {
 {
-    m_info_log = TRY(String::from_utf8(""sv));
+    m_info_log = String {};
 
 
     GLSL::Linker linker;
     GLSL::Linker linker;
 
 

+ 1 - 1
Userland/Libraries/LibGL/Shaders/Shader.cpp

@@ -24,7 +24,7 @@ ErrorOr<void> Shader::add_source(StringView source_code)
 
 
 ErrorOr<void> Shader::compile()
 ErrorOr<void> Shader::compile()
 {
 {
-    m_info_log = TRY(String::from_utf8(""sv));
+    m_info_log = String {};
 
 
     GLSL::Compiler compiler;
     GLSL::Compiler compiler;
 
 

+ 1 - 1
Userland/Libraries/LibGLSL/Compiler.cpp

@@ -11,7 +11,7 @@ namespace GLSL {
 ErrorOr<NonnullOwnPtr<ObjectFile>> Compiler::compile(Vector<String> const&)
 ErrorOr<NonnullOwnPtr<ObjectFile>> Compiler::compile(Vector<String> const&)
 {
 {
     // FIXME: implement this function
     // FIXME: implement this function
-    m_messages = TRY(String::from_utf8(""sv));
+    m_messages = {};
     return adopt_own(*new ObjectFile());
     return adopt_own(*new ObjectFile());
 }
 }
 
 

+ 1 - 1
Userland/Libraries/LibGLSL/Linker.cpp

@@ -11,7 +11,7 @@ namespace GLSL {
 ErrorOr<NonnullOwnPtr<LinkedShader>> Linker::link(Vector<ObjectFile const*> const&)
 ErrorOr<NonnullOwnPtr<LinkedShader>> Linker::link(Vector<ObjectFile const*> const&)
 {
 {
     // FIXME: implement this function
     // FIXME: implement this function
-    m_messages = TRY(String::from_utf8(""sv));
+    m_messages = {};
 
 
     GPU::IR::Shader shader;
     GPU::IR::Shader shader;
 
 

+ 1 - 1
Userland/Libraries/LibJS/Runtime/StringPrototype.cpp

@@ -489,7 +489,7 @@ JS_DEFINE_NATIVE_FUNCTION(StringPrototype::normalize)
 
 
     // 3. If form is undefined, let f be "NFC".
     // 3. If form is undefined, let f be "NFC".
     if (auto form_value = vm.argument(0); form_value.is_undefined()) {
     if (auto form_value = vm.argument(0); form_value.is_undefined()) {
-        form = TRY_OR_THROW_OOM(vm, String::from_utf8("NFC"sv));
+        form = String::from_utf8_short_string("NFC"sv);
     }
     }
     // 4. Else, let f be ? ToString(form).
     // 4. Else, let f be ? ToString(form).
     else {
     else {