From 99570cb0c47c6840aba47a50b7ce93071a148d38 Mon Sep 17 00:00:00 2001 From: Tim Ledbetter Date: Thu, 9 Feb 2023 19:19:17 +0000 Subject: [PATCH] LibGUI: Speed up Variant string conversion for string data Add a fast path to Variant::to_deprecated_string() to return a copy if the underlying data is of type DeprecatedString. This improves the performance of models with a lot of string data. --- Userland/Libraries/LibGUI/Variant.h | 1 + 1 file changed, 1 insertion(+) diff --git a/Userland/Libraries/LibGUI/Variant.h b/Userland/Libraries/LibGUI/Variant.h index 73322111df..2b4adc1559 100644 --- a/Userland/Libraries/LibGUI/Variant.h +++ b/Userland/Libraries/LibGUI/Variant.h @@ -204,6 +204,7 @@ public: { return visit( [](Empty) -> DeprecatedString { return "[null]"; }, + [](DeprecatedString v) { return v; }, [](Gfx::TextAlignment v) { return DeprecatedString::formatted("Gfx::TextAlignment::{}", Gfx::to_string(v)); }, [](Gfx::ColorRole v) { return DeprecatedString::formatted("Gfx::ColorRole::{}", Gfx::to_string(v)); }, [](Gfx::AlignmentRole v) { return DeprecatedString::formatted("Gfx::AlignmentRole::{}", Gfx::to_string(v)); },