diff --git a/lib/libimhex/include/hex/pattern_language/patterns/pattern.hpp b/lib/libimhex/include/hex/pattern_language/patterns/pattern.hpp index c63c4a179..944c4c18c 100644 --- a/lib/libimhex/include/hex/pattern_language/patterns/pattern.hpp +++ b/lib/libimhex/include/hex/pattern_language/patterns/pattern.hpp @@ -211,7 +211,7 @@ namespace hex::pl { this->m_local == other.m_local; } - [[nodiscard]] std::string formatDisplayValue(const std::string &value, const Token::Literal &literal) const { + [[nodiscard]] std::string calcDisplayValue(const std::string &value, const Token::Literal &literal) const { if (!this->m_formatterFunction.has_value()) return value; else { @@ -232,6 +232,14 @@ namespace hex::pl { } } + [[nodiscard]] std::string formatDisplayValue(const std::string &value, const Token::Literal &literal) const { + if (!this->m_cachedDisplayValue.has_value()) { + this->m_cachedDisplayValue = calcDisplayValue(value, literal); + } + + return this->m_cachedDisplayValue.value(); + } + protected: void createDefaultEntry(const std::string &value, Token::Literal &&literal) const { ImGui::TableNextRow(); @@ -279,6 +287,7 @@ namespace hex::pl { u32 m_color = 0x00; std::optional m_displayName; + mutable std::optional m_cachedDisplayValue; std::string m_variableName; std::optional m_comment; std::string m_typeName;