perf(pattern): save display value in cache (#466)
Co-authored-by: Dmitry Polshakov <dmitry.polshakov@dsr-corporation.com>
This commit is contained in:
parent
3801e0d60b
commit
d677762dff
@ -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<std::string> m_displayName;
|
||||
mutable std::optional<std::string> m_cachedDisplayValue;
|
||||
std::string m_variableName;
|
||||
std::optional<std::string> m_comment;
|
||||
std::string m_typeName;
|
||||
|
Loading…
x
Reference in New Issue
Block a user