diff options
Diffstat (limited to 'mediumlevelil.cpp')
| -rw-r--r-- | mediumlevelil.cpp | 33 |
1 files changed, 9 insertions, 24 deletions
diff --git a/mediumlevelil.cpp b/mediumlevelil.cpp index 04a7341f..0a28bd49 100644 --- a/mediumlevelil.cpp +++ b/mediumlevelil.cpp @@ -157,6 +157,7 @@ vector<uint64_t> MediumLevelILFunction::GetOperandList(ExprId expr, size_t listO size_t count; uint64_t* operands = BNMediumLevelILGetOperandList(m_object, expr, listOperand, &count); vector<uint64_t> result; + result.reserve(count); for (size_t i = 0; i < count; i++) result.push_back(operands[i]); BNMediumLevelILFreeOperandList(operands); @@ -338,19 +339,10 @@ bool MediumLevelILFunction::GetExprText(Architecture* arch, ExprId expr, vector< return false; tokens.clear(); + tokens.reserve(count); for (size_t i = 0; i < count; i++) - { - InstructionTextToken token; - token.type = list[i].type; - token.text = list[i].text; - token.value = list[i].value; - token.size = list[i].size; - token.operand = list[i].operand; - token.context = list[i].context; - token.confidence = list[i].confidence; - token.address = list[i].address; - tokens.push_back(token); - } + tokens.emplace_back(list[i].type, list[i].context, list[i].text, list[i].address, list[i].value, list[i].size, + list[i].operand, list[i].confidence); BNFreeInstructionText(list, count); return true; @@ -367,19 +359,10 @@ bool MediumLevelILFunction::GetInstructionText(Function* func, Architecture* arc return false; tokens.clear(); + tokens.reserve(count); for (size_t i = 0; i < count; i++) - { - InstructionTextToken token; - token.type = list[i].type; - token.text = list[i].text; - token.value = list[i].value; - token.size = list[i].size; - token.operand = list[i].operand; - token.context = list[i].context; - token.confidence = list[i].confidence; - token.address = list[i].address; - tokens.push_back(token); - } + tokens.emplace_back(list[i].type, list[i].context, list[i].text, list[i].address, list[i].value, list[i].size, + list[i].operand, list[i].confidence); BNFreeInstructionText(list, count); return true; @@ -412,6 +395,7 @@ vector<Ref<BasicBlock>> MediumLevelILFunction::GetBasicBlocks() const BNBasicBlock** blocks = BNGetMediumLevelILBasicBlockList(m_object, &count); vector<Ref<BasicBlock>> result; + result.reserve(count); for (size_t i = 0; i < count; i++) result.push_back(new BasicBlock(BNNewBasicBlockReference(blocks[i]))); @@ -696,6 +680,7 @@ unordered_map<size_t, BNILBranchDependence> MediumLevelILFunction::GetAllBranchD BNILBranchInstructionAndDependence* deps = BNGetAllMediumLevelILBranchDependence(m_object, instr, &count); unordered_map<size_t, BNILBranchDependence> result; + result.reserve(count); for (size_t i = 0; i < count; i++) result[deps[i].branch] = deps[i].dependence; |
