LibJS: Use Stream::format instead of manually formating and printing
This commit is contained in:
parent
6f6d6c654d
commit
fac7045a44
Notes:
sideshowbarker
2024-07-17 23:00:03 +09:00
Author: https://github.com/peterbb Commit: https://github.com/SerenityOS/serenity/commit/fac7045a44 Pull-request: https://github.com/SerenityOS/serenity/pull/18472 Reviewed-by: https://github.com/Hendiadyoin1 ✅
1 changed files with 2 additions and 7 deletions
|
@ -140,15 +140,10 @@ DeprecatedString strip_ansi(StringView format_string)
|
|||
template<typename... Args>
|
||||
ErrorOr<void> js_out(JS::PrintContext& print_context, CheckedFormatString<Args...> 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 {};
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue