TBTR: Add template replacement index validation to CheckCaches

This commit is contained in:
Jonathan G Rennison
2023-03-24 22:14:22 +00:00
parent 279e9c7ec6
commit 04aedf4798
2 changed files with 28 additions and 0 deletions

View File

@@ -35,6 +35,8 @@
#include "3rdparty/robin_hood/robin_hood.h"
#include <functional>
#include "safeguards.h"
TemplatePool _template_pool("TemplatePool");
@@ -330,3 +332,21 @@ void ReindexTemplateReplacementsRecursive()
}
}
}
std::string ValidateTemplateReplacementCaches()
{
robin_hood::unordered_flat_map<GroupID, TemplateID> saved_template_replacement_index = std::move(_template_replacement_index);
robin_hood::unordered_flat_map<GroupID, TemplateID> saved_template_replacement_index_recursive = std::move(_template_replacement_index_recursive);
ReindexTemplateReplacements();
bool match = (saved_template_replacement_index == _template_replacement_index);
bool match_recursive = (saved_template_replacement_index_recursive == _template_replacement_index_recursive);
_template_replacement_index = std::move(saved_template_replacement_index);
_template_replacement_index_recursive = std::move(saved_template_replacement_index_recursive);
if (!match) return "Index cache does not match";
if (!match_recursive) return "Recursive index cache does not match";
return "";
}