1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 16:47:36 +00:00

LibGfx/PortableFormat: Simplify read_number signature

The function signature goes from:
`bool read_number(Streamer& streamer, TValue* value)`
to
`ErrorOr<u16> read_number(Streamer& streamer)`

It allows us to, on one hand use `ErrorOr` for error propagation,
removing an out parameter in the meantime, and on the other hand remove
the useless template.
This commit is contained in:
Lucas CHOLLET 2023-03-12 15:02:03 -04:00 committed by Andreas Kling
parent 387894cdf2
commit 9052a6febf
3 changed files with 26 additions and 29 deletions

View file

@ -33,11 +33,11 @@ bool read_image_data(PGMLoadingContext& context, Streamer& streamer)
Vector<Gfx::Color> color_data;
if (context.type == PGMLoadingContext::Type::ASCII) {
u16 value;
while (true) {
if (!read_number(streamer, &value))
auto number_or_error = read_number(streamer);
if (number_or_error.is_error())
break;
auto value = number_or_error.value();
if (!read_whitespace(context, streamer))
break;