Browse Source

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.
Tim Ledbetter 2 years ago
parent
commit
99570cb0c4
1 changed files with 1 additions and 0 deletions
  1. 1 0
      Userland/Libraries/LibGUI/Variant.h

+ 1 - 0
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)); },