1
0
Fork 0
forked from suyu/suyu

Replace std::map with std::array for graphics event breakpoints, and allow the compiler to inline. Saves 1%+ in vertex heavy situations.

This commit is contained in:
Henrik Rydgard 2016-04-24 14:19:49 +02:00
parent 0964a3ff53
commit 01a1555b5d
3 changed files with 16 additions and 9 deletions

View file

@ -75,7 +75,7 @@ QVariant BreakPointModel::data(const QModelIndex& index, int role) const
case Role_IsEnabled: case Role_IsEnabled:
{ {
auto context = context_weak.lock(); auto context = context_weak.lock();
return context && context->breakpoints[event].enabled; return context && context->breakpoints[(int)event].enabled;
} }
default: default:
@ -110,7 +110,7 @@ bool BreakPointModel::setData(const QModelIndex& index, const QVariant& value, i
if (!context) if (!context)
return false; return false;
context->breakpoints[event].enabled = value == Qt::Checked; context->breakpoints[(int)event].enabled = value == Qt::Checked;
QModelIndex changed_index = createIndex(index.row(), 0); QModelIndex changed_index = createIndex(index.row(), 0);
emit dataChanged(changed_index, changed_index); emit dataChanged(changed_index, changed_index);
return true; return true;

View file

@ -40,10 +40,7 @@ using nihstro::DVLPHeader;
namespace Pica { namespace Pica {
void DebugContext::OnEvent(Event event, void* data) { void DebugContext::DoOnEvent(Event event, void* data) {
if (!breakpoints[event].enabled)
return;
{ {
std::unique_lock<std::mutex> lock(breakpoint_mutex); std::unique_lock<std::mutex> lock(breakpoint_mutex);

View file

@ -114,7 +114,15 @@ public:
* @param event Event which has happened * @param event Event which has happened
* @param data Optional data pointer (pass nullptr if unused). Needs to remain valid until Resume() is called. * @param data Optional data pointer (pass nullptr if unused). Needs to remain valid until Resume() is called.
*/ */
void OnEvent(Event event, void* data); void OnEvent(Event event, void* data) {
// This check is left in the header to allow the compiler to inline it.
if (!breakpoints[(int)event].enabled)
return;
// For the rest of event handling, call a separate function.
DoOnEvent(event, data);
}
void DoOnEvent(Event event, void *data);
/** /**
* Resume from the current breakpoint. * Resume from the current breakpoint.
@ -126,12 +134,14 @@ public:
* Delete all set breakpoints and resume emulation. * Delete all set breakpoints and resume emulation.
*/ */
void ClearBreakpoints() { void ClearBreakpoints() {
breakpoints.clear(); for (auto &bp : breakpoints) {
bp.enabled = false;
}
Resume(); Resume();
} }
// TODO: Evaluate if access to these members should be hidden behind a public interface. // TODO: Evaluate if access to these members should be hidden behind a public interface.
std::map<Event, BreakPoint> breakpoints; std::array<BreakPoint, (int)Event::NumEvents> breakpoints;
Event active_breakpoint; Event active_breakpoint;
bool at_breakpoint = false; bool at_breakpoint = false;