From fac7045a44d9e25bdb90d358555eadcd30606986 Mon Sep 17 00:00:00 2001 From: Peter Brottveit Bock Date: Sat, 22 Apr 2023 22:40:10 +0200 Subject: [PATCH] LibJS: Use Stream::format instead of manually formating and printing --- Userland/Libraries/LibJS/Print.cpp | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/Userland/Libraries/LibJS/Print.cpp b/Userland/Libraries/LibJS/Print.cpp index d789c270fa..e5d9f03bd9 100644 --- a/Userland/Libraries/LibJS/Print.cpp +++ b/Userland/Libraries/LibJS/Print.cpp @@ -140,15 +140,10 @@ DeprecatedString strip_ansi(StringView format_string) template ErrorOr js_out(JS::PrintContext& print_context, CheckedFormatString format_string, Args const&... args) { - DeprecatedString formatted; if (print_context.strip_ansi) - formatted = DeprecatedString::formatted(strip_ansi(format_string.view()), args...); + TRY(print_context.stream.format(strip_ansi(format_string.view()), args...)); else - formatted = DeprecatedString::formatted(format_string.view(), args...); - - auto bytes = formatted.bytes(); - while (!bytes.is_empty()) - bytes = bytes.slice(TRY(print_context.stream.write_some(bytes))); + TRY(print_context.stream.format(format_string.view(), args...)); return {}; }