Skip to content

Commit 6b6a779

Browse files
committed
[lldb][NFC] Always update m_cache_{hits/misses} in FormatCache
Summary: These two variables are only incremented under LLDB_CONFIGURATION_DEBUG but their value is always logged when verbose lldb formatter logging is enabled, which causes that our cache hit/miss log looks like this in non-Debug builds: ``` Cache hits: 0 - Cache Misses: 0 ... Cache hits: 0 - Cache Misses: 0 ... Cache hits: 0 - Cache Misses: 0 ``` This just always increments those two counters independent of build mode. Reviewers: JDevlieghere Reviewed By: JDevlieghere Differential Revision: https://reviews.llvm.org/D76687
1 parent aef982e commit 6b6a779

File tree

2 files changed

+3
-16
lines changed

2 files changed

+3
-16
lines changed

lldb/include/lldb/DataFormatters/FormatCache.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,13 +49,13 @@ class FormatCache {
4949
CacheMap m_map;
5050
std::recursive_mutex m_mutex;
5151

52-
uint64_t m_cache_hits;
53-
uint64_t m_cache_misses;
52+
uint64_t m_cache_hits = 0;
53+
uint64_t m_cache_misses = 0;
5454

5555
Entry &GetEntry(ConstString type);
5656

5757
public:
58-
FormatCache();
58+
FormatCache() = default;
5959

6060
template <typename ImplSP> bool Get(ConstString type, ImplSP &format_impl_sp);
6161
void Set(ConstString type, lldb::TypeFormatImplSP &format_sp);

lldb/source/DataFormatters/FormatCache.cpp

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -51,15 +51,6 @@ void FormatCache::Entry::Set(lldb::SyntheticChildrenSP synthetic_sp) {
5151
m_synthetic_sp = synthetic_sp;
5252
}
5353

54-
FormatCache::FormatCache()
55-
: m_map(), m_mutex()
56-
#ifdef LLDB_CONFIGURATION_DEBUG
57-
,
58-
m_cache_hits(0), m_cache_misses(0)
59-
#endif
60-
{
61-
}
62-
6354
FormatCache::Entry &FormatCache::GetEntry(ConstString type) {
6455
auto i = m_map.find(type), e = m_map.end();
6556
if (i != e)
@@ -87,15 +78,11 @@ bool FormatCache::Get(ConstString type, ImplSP &format_impl_sp) {
8778
std::lock_guard<std::recursive_mutex> guard(m_mutex);
8879
auto entry = GetEntry(type);
8980
if (entry.IsCached<ImplSP>()) {
90-
#ifdef LLDB_CONFIGURATION_DEBUG
9181
m_cache_hits++;
92-
#endif
9382
entry.Get(format_impl_sp);
9483
return true;
9584
}
96-
#ifdef LLDB_CONFIGURATION_DEBUG
9785
m_cache_misses++;
98-
#endif
9986
format_impl_sp.reset();
10087
return false;
10188
}

0 commit comments

Comments
 (0)