diff options
author | Nico Weber <thakis@chromium.org> | 2023-01-23 19:34:48 -0500 |
---|---|---|
committer | Linus Groh <mail@linusgroh.de> | 2023-01-24 14:45:27 +0000 |
commit | 95992a255eeadfa8a932d117370148a1f03dfdc8 (patch) | |
tree | c7c16192e3fe0a6e84416afe0d93cc22386356bc /Userland | |
parent | 81cc64f29c95362b4865f2d89a60780783caa201 (diff) | |
download | serenity-95992a255eeadfa8a932d117370148a1f03dfdc8.zip |
icc: Print every TagData object only once
When several tags refer to the same TagData object, we now only print
it the first time, and print "(see 'foob' above)" the following times,
where `foob` is the tag identifier where we printed it the first time.
Diffstat (limited to 'Userland')
-rw-r--r-- | Userland/Utilities/icc.cpp | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/Userland/Utilities/icc.cpp b/Userland/Utilities/icc.cpp index 2b6b189322..57c338813f 100644 --- a/Userland/Utilities/icc.cpp +++ b/Userland/Utilities/icc.cpp @@ -91,9 +91,19 @@ ErrorOr<int> serenity_main(Main::Arguments arguments) outln(""); outln("tags:"); - profile->for_each_tag([](auto tag_signature, auto tag_data) { + HashMap<Gfx::ICC::TagData*, Gfx::ICC::TagSignature> tag_data_to_first_signature; + profile->for_each_tag([&tag_data_to_first_signature](auto tag_signature, auto tag_data) { outln("{}: {}, offset {}, size {}", tag_signature, tag_data->type(), tag_data->offset(), tag_data->size()); + // Print tag data only the first time it's seen. + // (Different sigatures can refer to the same data.) + auto it = tag_data_to_first_signature.find(tag_data); + if (it != tag_data_to_first_signature.end()) { + outln(" (see {} above)", it->value); + return; + } + tag_data_to_first_signature.set(tag_data, tag_signature); + if (tag_data->type() == Gfx::ICC::CurveTagData::Type) { auto& curve = static_cast<Gfx::ICC::CurveTagData&>(*tag_data); if (curve.values().is_empty()) { |