From 7f04a6654604ad656590d4b15d585ab950f2aa89 Mon Sep 17 00:00:00 2001 From: hjk Date: Fri, 24 Feb 2023 12:17:03 +0100 Subject: [PATCH] Debugger: Introduce a cache for pre-rendered value columne entries Change-Id: Ibdcac8a5ccaa3eab0723205b913056530c510280 Reviewed-by: David Schulz --- src/plugins/debugger/watchdata.h | 3 +++ src/plugins/debugger/watchhandler.cpp | 19 +++++++++++++------ 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/src/plugins/debugger/watchdata.h b/src/plugins/debugger/watchdata.h index c25e1962f9c..4ef57eacf18 100644 --- a/src/plugins/debugger/watchdata.h +++ b/src/plugins/debugger/watchdata.h @@ -78,6 +78,9 @@ public: bool outdated = false; // \internal item is to be removed. double time = 0; // Time used on the dumper side to produce this item + mutable QString valueCache; // Pre-computed displayed value + void updateValueCache() const; // implemented in watchhandler.cpp + private: void parseHelper(const GdbMi &input, bool maySort); }; diff --git a/src/plugins/debugger/watchhandler.cpp b/src/plugins/debugger/watchhandler.cpp index f86bcb1c62e..4823a952b90 100644 --- a/src/plugins/debugger/watchhandler.cpp +++ b/src/plugins/debugger/watchhandler.cpp @@ -929,15 +929,22 @@ static QString displayName(const WatchItem *item) return result; } -static QString displayValue(const WatchItem *item) + +void WatchItem::updateValueCache() const { - QString result = truncateValue(formattedValue(item)); - result = watchModel(item)->removeNamespaces(result); - if (result.isEmpty() && item->address) - result += QString::fromLatin1("@0x" + QByteArray::number(item->address, 16)); + valueCache = truncateValue(formattedValue(this)); + valueCache = watchModel(this)->removeNamespaces(valueCache); + if (valueCache.isEmpty() && this->address) + valueCache += QString::fromLatin1("@0x" + QByteArray::number(this->address, 16)); // if (origaddr) // result += QString::fromLatin1(" (0x" + QByteArray::number(origaddr, 16) + ')'); - return result; +} + +static QString displayValue(const WatchItem *item) +{ + if (item->valueCache.isEmpty()) + item->updateValueCache(); + return item->valueCache; } static QString displayType(const WatchItem *item)