mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-06-16 12:58:33 +02:00
CodeDiffDialog: Construct Diff instance in CalculateSymbolsFromProfile() when necessary
We can move the construction of the Diff instance into the body of the if statement, so that we only construct this if the condition is true. While we're at it, we can move the symbol description string into the instance, getting rid of a copy. The function itself can also be const qualified.
This commit is contained in:
@ -279,7 +279,7 @@ void CodeDiffDialog::OnExclude()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<Diff> CodeDiffDialog::CalculateSymbolsFromProfile()
|
std::vector<Diff> CodeDiffDialog::CalculateSymbolsFromProfile() const
|
||||||
{
|
{
|
||||||
Profiler::ProfileStats prof_stats;
|
Profiler::ProfileStats prof_stats;
|
||||||
auto& blockstats = prof_stats.block_stats;
|
auto& blockstats = prof_stats.block_stats;
|
||||||
@ -288,23 +288,23 @@ std::vector<Diff> CodeDiffDialog::CalculateSymbolsFromProfile()
|
|||||||
current.reserve(20000);
|
current.reserve(20000);
|
||||||
|
|
||||||
// Convert blockstats to smaller struct Diff. Exclude repeat functions via symbols.
|
// Convert blockstats to smaller struct Diff. Exclude repeat functions via symbols.
|
||||||
for (auto& iter : blockstats)
|
for (const auto& iter : blockstats)
|
||||||
{
|
{
|
||||||
Diff tmp_diff;
|
|
||||||
std::string symbol = g_symbolDB.GetDescription(iter.addr);
|
std::string symbol = g_symbolDB.GetDescription(iter.addr);
|
||||||
if (!std::any_of(current.begin(), current.end(),
|
if (!std::any_of(current.begin(), current.end(),
|
||||||
[&symbol](Diff& v) { return v.symbol == symbol; }))
|
[&symbol](const Diff& v) { return v.symbol == symbol; }))
|
||||||
{
|
{
|
||||||
tmp_diff.symbol = symbol;
|
current.push_back(Diff{
|
||||||
tmp_diff.addr = iter.addr;
|
.addr = iter.addr,
|
||||||
tmp_diff.hits = iter.run_count;
|
.symbol = std::move(symbol),
|
||||||
tmp_diff.total_hits = iter.run_count;
|
.hits = static_cast<u32>(iter.run_count),
|
||||||
current.push_back(tmp_diff);
|
.total_hits = static_cast<u32>(iter.run_count),
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
sort(current.begin(), current.end(),
|
std::sort(current.begin(), current.end(),
|
||||||
[](const Diff& v1, const Diff& v2) { return (v1.symbol < v2.symbol); });
|
[](const Diff& v1, const Diff& v2) { return (v1.symbol < v2.symbol); });
|
||||||
|
|
||||||
return current;
|
return current;
|
||||||
}
|
}
|
||||||
|
@ -38,7 +38,7 @@ private:
|
|||||||
void ClearBlockCache();
|
void ClearBlockCache();
|
||||||
void OnClickItem();
|
void OnClickItem();
|
||||||
void OnRecord(bool enabled);
|
void OnRecord(bool enabled);
|
||||||
std::vector<Diff> CalculateSymbolsFromProfile();
|
std::vector<Diff> CalculateSymbolsFromProfile() const;
|
||||||
void OnInclude();
|
void OnInclude();
|
||||||
void OnExclude();
|
void OnExclude();
|
||||||
void RemoveMissingSymbolsFromIncludes(const std::vector<Diff>& symbol_diff);
|
void RemoveMissingSymbolsFromIncludes(const std::vector<Diff>& symbol_diff);
|
||||||
|
Reference in New Issue
Block a user