From 516d800b01c4309c7d9ea309f9cabd8905280311 Mon Sep 17 00:00:00 2001 From: Nico Weber Date: Fri, 6 Jan 2023 15:57:31 -0500 Subject: [PATCH] icc: Extract out_optional() function --- Userland/Utilities/icc.cpp | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/Userland/Utilities/icc.cpp b/Userland/Utilities/icc.cpp index 55180835da..6c75f4b6a9 100644 --- a/Userland/Utilities/icc.cpp +++ b/Userland/Utilities/icc.cpp @@ -10,6 +10,16 @@ #include #include +template +static void out_optional(char const* label, Optional optional) +{ + out("{}: ", label); + if (optional.has_value()) + outln("{}", *optional); + else + outln("(not set)"); +} + ErrorOr serenity_main(Main::Arguments arguments) { Core::ArgsParser args_parser; @@ -49,12 +59,7 @@ ErrorOr serenity_main(Main::Arguments arguments) outln("rendering intent: {}", Gfx::ICC::rendering_intent_name(profile->rendering_intent())); outln("pcs illuminant: {}", profile->pcs_illuminant()); - - out("id: "); - if (auto id = profile->id(); id.has_value()) - outln("{}", *id); - else - outln("(not set)"); + out_optional("id", profile->id()); return 0; }