From 70e3d0ea55e8b9385168d389fcba16a283f20214 Mon Sep 17 00:00:00 2001 From: Adrian Prantl Date: Tue, 10 Dec 2019 10:58:06 -0800 Subject: [FormatManager] Move Language lookup into the obviously non-cached part (NFC) This refactoring makes the lookup caching easier to reason about. This has no observable effect although it does slightly change what is being cached. - Before this patch a negative lookup in the LanguageCategory would be cached, but a positive wouldn't. - After this patch LanguageCategory lookups aren't cached by FormatManager, period. (LanguageCategory has its own FormatCache for this!) Differential Revision: https://reviews.llvm.org/D71289 --- lldb/source/DataFormatters/FormatManager.cpp | 32 ++++++++++++++-------------- 1 file changed, 16 insertions(+), 16 deletions(-) (limited to 'lldb/source/DataFormatters/FormatManager.cpp') diff --git a/lldb/source/DataFormatters/FormatManager.cpp b/lldb/source/DataFormatters/FormatManager.cpp index db15a7f7a4cc..8c7967aaf1e1 100644 --- a/lldb/source/DataFormatters/FormatManager.cpp +++ b/lldb/source/DataFormatters/FormatManager.cpp @@ -630,7 +630,22 @@ ImplSP FormatManager::Get(ValueObject &valobj, return retval_sp; Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_DATAFORMATTERS)); - LLDB_LOGF(log, "[%s] Search failed. Giving hardcoded a chance.", __FUNCTION__); + + LLDB_LOGF(log, "[%s] Search failed. Giving language a chance.", __FUNCTION__); + for (lldb::LanguageType lang_type : match_data.GetCandidateLanguages()) { + if (LanguageCategory *lang_category = GetCategoryForLanguage(lang_type)) { + ImplSP retval_sp; + if (lang_category->Get(match_data, retval_sp)) + if (retval_sp) { + LLDB_LOGF(log, "[%s] Language search success. Returning.", + __FUNCTION__); + return retval_sp; + } + } + } + + LLDB_LOGF(log, "[%s] Search failed. Giving hardcoded a chance.", + __FUNCTION__); return GetHardcoded(match_data); } @@ -655,21 +670,6 @@ ImplSP FormatManager::GetCached(FormattersMatchData &match_data) { } m_categories_map.Get(match_data, retval_sp); - if (!retval_sp) { - LLDB_LOGF(log, "[%s] Search failed. Giving language a chance.", - __FUNCTION__); - for (lldb::LanguageType lang_type : match_data.GetCandidateLanguages()) { - if (LanguageCategory *lang_category = GetCategoryForLanguage(lang_type)) { - if (lang_category->Get(match_data, retval_sp)) - break; - } - } - if (retval_sp) { - LLDB_LOGF(log, "[%s] Language search success. Returning.", __FUNCTION__); - return retval_sp; - } - } - if (match_data.GetTypeForCache() && (!retval_sp || !retval_sp->NonCacheable())) { LLDB_LOGF(log, "[%s] Caching %p for type %s", __FUNCTION__, static_cast(retval_sp.get()), -- cgit v1.2.3