Merge pull request #11908 from lioncash/strcopy

Debugger: Remove some trivial string copies
This commit is contained in:
Admiral H. Curtiss 2023-06-08 20:54:21 +02:00 committed by GitHub
commit 0d07ebab25
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 17 additions and 17 deletions

View File

@ -251,7 +251,7 @@ void BreakpointDialog::OnAddressTypeChanged()
void BreakpointDialog::accept() void BreakpointDialog::accept()
{ {
auto invalid_input = [this](QString field) { auto invalid_input = [this](const QString& field) {
ModalMessageBox::critical(this, tr("Error"), ModalMessageBox::critical(this, tr("Error"),
tr("Invalid input for the field \"%1\"").arg(field)); tr("Invalid input for the field \"%1\"").arg(field));
}; };

View File

@ -168,7 +168,7 @@ void BreakpointWidget::Update()
int i = 0; int i = 0;
m_table->setRowCount(i); m_table->setRowCount(i);
const auto create_item = [](const QString string = {}) { const auto create_item = [](const QString& string = {}) {
QTableWidgetItem* item = new QTableWidgetItem(string); QTableWidgetItem* item = new QTableWidgetItem(string);
item->setFlags(Qt::ItemIsEnabled | Qt::ItemIsSelectable); item->setFlags(Qt::ItemIsEnabled | Qt::ItemIsSelectable);
return item; return item;

View File

@ -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,22 +288,22 @@ 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;
@ -361,7 +361,7 @@ void CodeDiffDialog::Update(bool include)
OnExclude(); OnExclude();
} }
const auto create_item = [](const QString string = {}, const u32 address = 0x00000000) { const auto create_item = [](const QString& string = {}, const u32 address = 0x00000000) {
QTableWidgetItem* item = new QTableWidgetItem(string); QTableWidgetItem* item = new QTableWidgetItem(string);
item->setData(Qt::UserRole, address); item->setData(Qt::UserRole, address);
item->setFlags(Qt::ItemIsEnabled | Qt::ItemIsSelectable); item->setFlags(Qt::ItemIsEnabled | Qt::ItemIsSelectable);

View File

@ -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);

View File

@ -609,7 +609,7 @@ AddressSpace::Type MemoryViewWidget::GetAddressSpace() const
return m_address_space; return m_address_space;
} }
std::vector<u8> MemoryViewWidget::ConvertTextToBytes(Type type, QString input_text) std::vector<u8> MemoryViewWidget::ConvertTextToBytes(Type type, QStringView input_text) const
{ {
if (type == Type::Null) if (type == Type::Null)
return {}; return {};

View File

@ -60,7 +60,7 @@ public:
void UpdateFont(); void UpdateFont();
void ToggleBreakpoint(u32 addr, bool row); void ToggleBreakpoint(u32 addr, bool row);
std::vector<u8> ConvertTextToBytes(Type type, QString input_text); std::vector<u8> ConvertTextToBytes(Type type, QStringView input_text) const;
void SetAddressSpace(AddressSpace::Type address_space); void SetAddressSpace(AddressSpace::Type address_space);
AddressSpace::Type GetAddressSpace() const; AddressSpace::Type GetAddressSpace() const;
void SetDisplay(Type type, int bytes_per_row, int alignment, bool dual_view); void SetDisplay(Type type, int bytes_per_row, int alignment, bool dual_view);