From 739798e075f0edefb1c22e30bde8039746231838 Mon Sep 17 00:00:00 2001 From: Timothy Flynn Date: Wed, 14 Sep 2022 06:32:56 -0400 Subject: [PATCH] LibUnicode: Use recently added Core::Stream::read_all in code generators The generators had a manual implementation when Core::Stream did not have a read_all method. --- .../Tools/CodeGenerators/LibUnicode/GeneratorUtil.h | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/Meta/Lagom/Tools/CodeGenerators/LibUnicode/GeneratorUtil.h b/Meta/Lagom/Tools/CodeGenerators/LibUnicode/GeneratorUtil.h index d9afa5fcda..b033a24d41 100644 --- a/Meta/Lagom/Tools/CodeGenerators/LibUnicode/GeneratorUtil.h +++ b/Meta/Lagom/Tools/CodeGenerators/LibUnicode/GeneratorUtil.h @@ -332,17 +332,9 @@ inline ErrorOr> open_file(StringView p inline ErrorOr read_json_file(StringView path) { auto file = TRY(open_file(path, Core::Stream::OpenMode::Read)); + auto buffer = TRY(file->read_all()); - StringBuilder builder; - Array buffer; - - // FIXME: When Core::Stream supports reading an entire file, use that. - while (TRY(file->can_read_line())) { - auto bytes_read = TRY(file->read(buffer)); - TRY(builder.try_append(StringView { bytes_read })); - } - - return JsonValue::from_string(builder.build()); + return JsonValue::from_string(buffer); } inline ErrorOr path_to_dir_iterator(String path, StringView subpath = "main"sv)