diff --git a/Userland/Libraries/LibJS/Console.cpp b/Userland/Libraries/LibJS/Console.cpp index d236230666..41740defba 100644 --- a/Userland/Libraries/LibJS/Console.cpp +++ b/Userland/Libraries/LibJS/Console.cpp @@ -7,13 +7,13 @@ */ #include +#include #include #include #include #include #include #include -#include namespace JS { @@ -501,16 +501,16 @@ void Console::report_exception(JS::Error const& exception, bool in_promise) cons ThrowCompletionOr Console::value_vector_to_string(MarkedVector const& values) { auto& vm = realm().vm(); - ThrowableStringBuilder builder(vm); + StringBuilder builder; for (auto const& item : values) { if (!builder.is_empty()) - MUST_OR_THROW_OOM(builder.append(' ')); + builder.append(' '); - MUST_OR_THROW_OOM(builder.append(TRY(item.to_string(vm)))); + builder.append(TRY(item.to_string(vm))); } - return builder.to_string(); + return MUST(builder.to_string()); } ThrowCompletionOr Console::format_time_since(Core::ElapsedTimer timer) @@ -520,27 +520,26 @@ ThrowCompletionOr Console::format_time_since(Core::ElapsedTimer timer) auto elapsed_ms = timer.elapsed_time().to_milliseconds(); auto duration = TRY(Temporal::balance_duration(vm, 0, 0, 0, 0, elapsed_ms, 0, "0"_sbigint, "year"sv)); - auto append = [&](ThrowableStringBuilder& builder, auto format, auto number) -> ThrowCompletionOr { + auto append = [&](auto& builder, auto format, auto number) { if (!builder.is_empty()) - MUST_OR_THROW_OOM(builder.append(' ')); - MUST_OR_THROW_OOM(builder.appendff(format, number)); - return {}; + builder.append(' '); + builder.appendff(format, number); }; - ThrowableStringBuilder builder(vm); + StringBuilder builder; if (duration.days > 0) - MUST_OR_THROW_OOM(append(builder, "{:.0} day(s)"sv, duration.days)); + append(builder, "{:.0} day(s)"sv, duration.days); if (duration.hours > 0) - MUST_OR_THROW_OOM(append(builder, "{:.0} hour(s)"sv, duration.hours)); + append(builder, "{:.0} hour(s)"sv, duration.hours); if (duration.minutes > 0) - MUST_OR_THROW_OOM(append(builder, "{:.0} minute(s)"sv, duration.minutes)); + append(builder, "{:.0} minute(s)"sv, duration.minutes); if (duration.seconds > 0 || duration.milliseconds > 0) { double combined_seconds = duration.seconds + (0.001 * duration.milliseconds); - MUST_OR_THROW_OOM(append(builder, "{:.3} seconds"sv, combined_seconds)); + append(builder, "{:.3} seconds"sv, combined_seconds); } - return builder.to_string(); + return MUST(builder.to_string()); } // 2.1. Logger(logLevel, args), https://console.spec.whatwg.org/#logger diff --git a/Userland/Libraries/LibJS/Runtime/PrimitiveString.cpp b/Userland/Libraries/LibJS/Runtime/PrimitiveString.cpp index 2544c43d31..600ad31d72 100644 --- a/Userland/Libraries/LibJS/Runtime/PrimitiveString.cpp +++ b/Userland/Libraries/LibJS/Runtime/PrimitiveString.cpp @@ -7,13 +7,13 @@ #include #include +#include #include #include #include #include #include #include -#include #include #include diff --git a/Userland/Libraries/LibWeb/HTML/WorkerDebugConsoleClient.cpp b/Userland/Libraries/LibWeb/HTML/WorkerDebugConsoleClient.cpp index 659d2cd6f0..c478e572e2 100644 --- a/Userland/Libraries/LibWeb/HTML/WorkerDebugConsoleClient.cpp +++ b/Userland/Libraries/LibWeb/HTML/WorkerDebugConsoleClient.cpp @@ -4,10 +4,10 @@ * SPDX-License-Identifier: BSD-2-Clause */ +#include #include #include #include -#include #include #include @@ -40,12 +40,12 @@ JS::ThrowCompletionOr WorkerDebugConsoleClient::printer(JS::Console:: if (log_level == JS::Console::LogLevel::Trace) { auto trace = arguments.get(); - JS::ThrowableStringBuilder builder(vm); + StringBuilder builder; if (!trace.label.is_empty()) - MUST_OR_THROW_OOM(builder.appendff("{}\033[36;1m{}\033[0m\n", indent, trace.label)); + builder.appendff("{}\033[36;1m{}\033[0m\n", indent, trace.label); for (auto& function_name : trace.stack) - MUST_OR_THROW_OOM(builder.appendff("{}-> {}\n", indent, function_name)); + builder.appendff("{}-> {}\n", indent, function_name); dbgln("{}", builder.string_view()); return JS::js_undefined(); diff --git a/Userland/Libraries/LibWeb/WebAssembly/WebAssembly.cpp b/Userland/Libraries/LibWeb/WebAssembly/WebAssembly.cpp index db1090acdb..358aee16b1 100644 --- a/Userland/Libraries/LibWeb/WebAssembly/WebAssembly.cpp +++ b/Userland/Libraries/LibWeb/WebAssembly/WebAssembly.cpp @@ -7,6 +7,7 @@ #include #include +#include #include #include #include @@ -15,7 +16,6 @@ #include #include #include -#include #include #include #include @@ -283,10 +283,10 @@ JS::ThrowCompletionOr instantiate_module(JS::VM& vm, Wasm::Module const& auto link_result = linker.finish(); if (link_result.is_error()) { // FIXME: Throw a LinkError. - JS::ThrowableStringBuilder builder(vm); - MUST_OR_THROW_OOM(builder.append("LinkError: Missing "sv)); - MUST_OR_THROW_OOM(builder.join(' ', link_result.error().missing_imports)); - return vm.throw_completion(MUST_OR_THROW_OOM(builder.to_string())); + StringBuilder builder; + builder.append("LinkError: Missing "sv); + builder.join(' ', link_result.error().missing_imports); + return vm.throw_completion(MUST(builder.to_string())); } auto instance_result = s_abstract_machine.instantiate(module, link_result.release_value()); diff --git a/Userland/Services/WebContent/WebContentConsoleClient.cpp b/Userland/Services/WebContent/WebContentConsoleClient.cpp index da80cdd9ab..917348070a 100644 --- a/Userland/Services/WebContent/WebContentConsoleClient.cpp +++ b/Userland/Services/WebContent/WebContentConsoleClient.cpp @@ -7,13 +7,13 @@ */ #include "WebContentConsoleClient.h" +#include #include #include #include #include #include #include -#include #include #include #include @@ -132,21 +132,19 @@ void WebContentConsoleClient::clear() // 2.3. Printer(logLevel, args[, options]), https://console.spec.whatwg.org/#printer JS::ThrowCompletionOr WebContentConsoleClient::printer(JS::Console::LogLevel log_level, PrinterArguments arguments) { - auto& vm = m_console.realm().vm(); - auto styling = escape_html_entities(m_current_message_style.string_view()); m_current_message_style.clear(); if (log_level == JS::Console::LogLevel::Trace) { auto trace = arguments.get(); - JS::ThrowableStringBuilder html(vm); + StringBuilder html; if (!trace.label.is_empty()) - MUST_OR_THROW_OOM(html.appendff("{}
", styling, escape_html_entities(trace.label))); + html.appendff("{}
", styling, escape_html_entities(trace.label)); - MUST_OR_THROW_OOM(html.append(""sv)); + html.append(""sv); for (auto& function_name : trace.stack) - MUST_OR_THROW_OOM(html.appendff("-> {}
", escape_html_entities(function_name))); - MUST_OR_THROW_OOM(html.append("
"sv)); + html.appendff("-> {}
", escape_html_entities(function_name)); + html.append("
"sv); print_html(html.string_view()); return JS::js_undefined(); @@ -161,31 +159,31 @@ JS::ThrowCompletionOr WebContentConsoleClient::printer(JS::Console::L auto output = TRY(generically_format_values(arguments.get>())); m_console.output_debug_message(log_level, output); - JS::ThrowableStringBuilder html(vm); + StringBuilder html; switch (log_level) { case JS::Console::LogLevel::Debug: - MUST_OR_THROW_OOM(html.appendff("(d) "sv, styling)); + html.appendff("(d) "sv, styling); break; case JS::Console::LogLevel::Error: - MUST_OR_THROW_OOM(html.appendff("(e) "sv, styling)); + html.appendff("(e) "sv, styling); break; case JS::Console::LogLevel::Info: - MUST_OR_THROW_OOM(html.appendff("(i) "sv, styling)); + html.appendff("(i) "sv, styling); break; case JS::Console::LogLevel::Log: - MUST_OR_THROW_OOM(html.appendff(" "sv, styling)); + html.appendff(" "sv, styling); break; case JS::Console::LogLevel::Warn: case JS::Console::LogLevel::CountReset: - MUST_OR_THROW_OOM(html.appendff("(w) "sv, styling)); + html.appendff("(w) "sv, styling); break; default: - MUST_OR_THROW_OOM(html.appendff(""sv, styling)); + html.appendff(""sv, styling); break; } - MUST_OR_THROW_OOM(html.append(escape_html_entities(output))); - MUST_OR_THROW_OOM(html.append(""sv)); + html.append(escape_html_entities(output)); + html.append(""sv); print_html(html.string_view()); return JS::js_undefined(); diff --git a/Userland/Utilities/js.cpp b/Userland/Utilities/js.cpp index 6b7ab7ef10..78fe2e699c 100644 --- a/Userland/Utilities/js.cpp +++ b/Userland/Utilities/js.cpp @@ -7,6 +7,7 @@ */ #include +#include #include #include #include @@ -23,7 +24,6 @@ #include #include #include -#include #include #include #include @@ -503,12 +503,12 @@ public: if (log_level == JS::Console::LogLevel::Trace) { auto trace = arguments.get(); - JS::ThrowableStringBuilder builder(*g_vm); + StringBuilder builder; if (!trace.label.is_empty()) - MUST_OR_THROW_OOM(builder.appendff("{}\033[36;1m{}\033[0m\n", indent, trace.label)); + builder.appendff("{}\033[36;1m{}\033[0m\n", indent, trace.label); for (auto& function_name : trace.stack) - MUST_OR_THROW_OOM(builder.appendff("{}-> {}\n", indent, function_name)); + builder.appendff("{}-> {}\n", indent, function_name); outln("{}", builder.string_view()); return JS::js_undefined();