From 1df49afa5522d73d509d20db9588294fe259085f Mon Sep 17 00:00:00 2001 From: Brian Potchik Date: Thu, 11 Jan 2018 17:10:34 -0500 Subject: API Temporary Object Elimination. --- function.cpp | 49 ++++++++++++++++++++++++------------------------- 1 file changed, 24 insertions(+), 25 deletions(-) (limited to 'function.cpp') diff --git a/function.cpp b/function.cpp index 2d8db04c..1226e399 100644 --- a/function.cpp +++ b/function.cpp @@ -504,11 +504,7 @@ Confidence> Function::GetParameterVariables() const vector varList; for (size_t i = 0; i < vars.count; i++) { - Variable var; - var.type = vars.vars[i].type; - var.index = vars.vars[i].index; - var.storage = vars.vars[i].storage; - varList.push_back(var); + varList.emplace_back(vars.vars[i].type, vars.vars[i].index, vars.vars[i].storage); } Confidence> result(varList, vars.confidence); BNFreeParameterVariables(&vars); @@ -569,13 +565,14 @@ void Function::SetAutoCallingConvention(const Confidence> void Function::SetAutoParameterVariables(const Confidence>& vars) { BNParameterVariablesWithConfidence varConf; - varConf.vars = new BNVariable[vars.GetValue().size()]; - varConf.count = vars.GetValue().size(); - for (size_t i = 0; i < vars.GetValue().size(); i++) + varConf.vars = new BNVariable[vars->size()]; + varConf.count = vars->size(); + size_t i = 0; + for (auto it = vars->begin(); it != vars->end(); ++it, ++i) { - varConf.vars[i].type = vars.GetValue()[i].type; - varConf.vars[i].index = vars.GetValue()[i].index; - varConf.vars[i].storage = vars.GetValue()[i].storage; + varConf.vars[i].type = it->type; + varConf.vars[i].index = it->index; + varConf.vars[i].storage = it->storage; } varConf.confidence = vars.GetConfidence(); @@ -614,11 +611,12 @@ void Function::SetAutoStackAdjustment(const Confidence& stackAdjust) void Function::SetAutoClobberedRegisters(const Confidence>& clobbered) { BNRegisterSetWithConfidence regs; - regs.regs = new uint32_t[clobbered.GetValue().size()]; - regs.count = clobbered.GetValue().size(); + regs.regs = new uint32_t[clobbered->size()]; + regs.count = clobbered->size(); + size_t i = 0; - for (auto reg : clobbered.GetValue()) - regs.regs[i++] = reg; + for (auto it = clobbered->begin(); it != clobbered->end(); ++it, ++i) + regs.regs[i] = *it; regs.confidence = clobbered.GetConfidence(); BNSetAutoFunctionClobberedRegisters(m_object, ®s); delete[] regs.regs; @@ -652,13 +650,14 @@ void Function::SetCallingConvention(const Confidence>& co void Function::SetParameterVariables(const Confidence>& vars) { BNParameterVariablesWithConfidence varConf; - varConf.vars = new BNVariable[vars.GetValue().size()]; - varConf.count = vars.GetValue().size(); - for (size_t i = 0; i < vars.GetValue().size(); i++) + varConf.vars = new BNVariable[vars->size()]; + varConf.count = vars->size(); + size_t i = 0; + for (auto it = vars->begin(); it != vars->end(); ++it, ++i) { - varConf.vars[i].type = vars.GetValue()[i].type; - varConf.vars[i].index = vars.GetValue()[i].index; - varConf.vars[i].storage = vars.GetValue()[i].storage; + varConf.vars[i].type = it->type; + varConf.vars[i].index = it->index; + varConf.vars[i].storage = it->storage; } varConf.confidence = vars.GetConfidence(); @@ -697,11 +696,11 @@ void Function::SetStackAdjustment(const Confidence& stackAdjust) void Function::SetClobberedRegisters(const Confidence>& clobbered) { BNRegisterSetWithConfidence regs; - regs.regs = new uint32_t[clobbered.GetValue().size()]; - regs.count = clobbered.GetValue().size(); + regs.regs = new uint32_t[clobbered->size()]; + regs.count = clobbered->size(); size_t i = 0; - for (auto reg : clobbered.GetValue()) - regs.regs[i++] = reg; + for (auto it = clobbered->begin(); it != clobbered->end(); ++it, ++i) + regs.regs[i] = *it; regs.confidence = clobbered.GetConfidence(); BNSetUserFunctionClobberedRegisters(m_object, ®s); delete[] regs.regs; -- cgit v1.3.1