Permalink
Browse files

DolphinQt2/RegisterWidget: std::move std::function instances in AddRe…

…gister()

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.
  • Loading branch information...
lioncash committed Jun 19, 2018
1 parent 18c3e03 commit 6066ca30b27b5ca25fe5d59f315ecd137d5c52f5
Showing with 8 additions and 6 deletions.
  1. +8 −6 Source/Core/DolphinQt2/Debugger/RegisterWidget.cpp
@@ -4,18 +4,20 @@
#include "DolphinQt2/Debugger/RegisterWidget.h"
#include <utility>
#include <QHeaderView>
#include <QMenu>
#include <QTableWidget>
#include <QVBoxLayout>
#include "Core/Core.h"
#include "Core/HW/ProcessorInterface.h"
#include "Core/PowerPC/PowerPC.h"
#include "DolphinQt2/Host.h"
#include "DolphinQt2/QtUtils/ActionHelper.h"
#include "DolphinQt2/Settings.h"
#include <QHeaderView>
#include <QMenu>
#include <QTableWidget>
#include <QVBoxLayout>
RegisterWidget::RegisterWidget(QWidget* parent) : QDockWidget(parent)
{
setWindowTitle(tr("Registers"));
@@ -335,7 +337,7 @@ void RegisterWidget::PopulateTable()
void RegisterWidget::AddRegister(int row, int column, RegisterType type, std::string register_name,
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)
m_table->setRowCount(row + 1);

0 comments on commit 6066ca3

Please sign in to comment.