DolphinQt2/RegisterWidget: std::move std::function instances in AddRegister()

These can be moved into the RegisterColumn constructor, which avoids
potential allocations in the case a std::function would otherwise need
to allocate to hold all of it's captured data.

Also tidy up the inclusion order while we're at it.
This commit is contained in:
Lioncash 2018-06-19 13:36:52 -04:00
parent 18c3e0302f
commit 6066ca30b2
1 changed files with 8 additions and 6 deletions

View File

@ -4,6 +4,13 @@
#include "DolphinQt2/Debugger/RegisterWidget.h" #include "DolphinQt2/Debugger/RegisterWidget.h"
#include <utility>
#include <QHeaderView>
#include <QMenu>
#include <QTableWidget>
#include <QVBoxLayout>
#include "Core/Core.h" #include "Core/Core.h"
#include "Core/HW/ProcessorInterface.h" #include "Core/HW/ProcessorInterface.h"
#include "Core/PowerPC/PowerPC.h" #include "Core/PowerPC/PowerPC.h"
@ -11,11 +18,6 @@
#include "DolphinQt2/QtUtils/ActionHelper.h" #include "DolphinQt2/QtUtils/ActionHelper.h"
#include "DolphinQt2/Settings.h" #include "DolphinQt2/Settings.h"
#include <QHeaderView>
#include <QMenu>
#include <QTableWidget>
#include <QVBoxLayout>
RegisterWidget::RegisterWidget(QWidget* parent) : QDockWidget(parent) RegisterWidget::RegisterWidget(QWidget* parent) : QDockWidget(parent)
{ {
setWindowTitle(tr("Registers")); setWindowTitle(tr("Registers"));
@ -335,7 +337,7 @@ void RegisterWidget::PopulateTable()
void RegisterWidget::AddRegister(int row, int column, RegisterType type, std::string register_name, void RegisterWidget::AddRegister(int row, int column, RegisterType type, std::string register_name,
std::function<u64()> get_reg, std::function<void(u64)> set_reg) std::function<u64()> get_reg, std::function<void(u64)> set_reg)
{ {
auto* value = new RegisterColumn(type, get_reg, set_reg); auto* value = new RegisterColumn(type, std::move(get_reg), std::move(set_reg));
if (m_table->rowCount() <= row) if (m_table->rowCount() <= row)
m_table->setRowCount(row + 1); m_table->setRowCount(row + 1);