From 1ef802ee9a14e6274b3e60db873965b794f49abe Mon Sep 17 00:00:00 2001 From: Christoph Egger Date: Fri, 20 Mar 2015 12:46:55 +0100 Subject: [PATCH] Change from list to vector We want to index into that array so a vector is the better data structure --- src/core/BasicBlock.cxx | 2 +- src/core/BasicBlock.hxx | 4 ++-- src/disassembler/Disassembler.hxx | 4 ++-- src/disassembler/llvm/LLVMDisassembler.cxx | 4 ++-- src/disassembler/llvm/LLVMDisassembler.hxx | 2 +- src/gui/widgets/BasicBlockWidget.hxx | 5 +---- 6 files changed, 9 insertions(+), 12 deletions(-) diff --git a/src/core/BasicBlock.cxx b/src/core/BasicBlock.cxx index 7af6bd8..a88b399 100644 --- a/src/core/BasicBlock.cxx +++ b/src/core/BasicBlock.cxx @@ -90,6 +90,6 @@ BasicBlock* BasicBlock::deserialize(QXmlStreamReader& stream, InformationManager return block; } -std::list BasicBlock::getInstructions() const { +std::vector BasicBlock::getInstructions() const { return manager->getDisassembler()->getInstructions(this); } diff --git a/src/core/BasicBlock.hxx b/src/core/BasicBlock.hxx index 3f87787..918f273 100644 --- a/src/core/BasicBlock.hxx +++ b/src/core/BasicBlock.hxx @@ -4,7 +4,7 @@ #include #include #include -#include +#include class Instruction; class Disassembler; @@ -36,7 +36,7 @@ public: return s.str(); } - std::list getInstructions() const; + std::vector getInstructions() const; void serialize(QXmlStreamWriter& stream); static BasicBlock* deserialize(QXmlStreamReader& stream, InformationManager* manager); diff --git a/src/disassembler/Disassembler.hxx b/src/disassembler/Disassembler.hxx index 78c67c6..ffcc889 100644 --- a/src/disassembler/Disassembler.hxx +++ b/src/disassembler/Disassembler.hxx @@ -3,7 +3,7 @@ #include #include -#include +#include #include "Instruction.hxx" @@ -24,7 +24,7 @@ public: std::function fun) = 0; virtual Function * disassembleFunctionAt(uint64_t address, const std::string& name = "") = 0; - virtual std::list getInstructions(const BasicBlock* block) = 0; + virtual std::vector getInstructions(const BasicBlock* block) = 0; }; #endif diff --git a/src/disassembler/llvm/LLVMDisassembler.cxx b/src/disassembler/llvm/LLVMDisassembler.cxx index 3023f93..990ed4f 100644 --- a/src/disassembler/llvm/LLVMDisassembler.cxx +++ b/src/disassembler/llvm/LLVMDisassembler.cxx @@ -526,8 +526,8 @@ void LLVMDisassembler::readSections() { // } template -std::list LLVMDisassembler::getInstructions(const BasicBlock *block) { - std::list result; +std::vector LLVMDisassembler::getInstructions(const BasicBlock *block) { + std::vector result; SectionRef text_section = getTextSection(); uint64_t base_address; text_section.getAddress(base_address); diff --git a/src/disassembler/llvm/LLVMDisassembler.hxx b/src/disassembler/llvm/LLVMDisassembler.hxx index a64dc2c..df01c9a 100644 --- a/src/disassembler/llvm/LLVMDisassembler.hxx +++ b/src/disassembler/llvm/LLVMDisassembler.hxx @@ -31,7 +31,7 @@ public: const std::string&)> fun); Function * disassembleFunctionAt(uint64_t address, const std::string& name = ""); - std::list getInstructions(const BasicBlock* block); + std::vector getInstructions(const BasicBlock* block); private: // http://llvm.org/docs/doxygen/html/MCObjectDisassembler_8cpp_source.html +197 diff --git a/src/gui/widgets/BasicBlockWidget.hxx b/src/gui/widgets/BasicBlockWidget.hxx index 22bc220..e3d3611 100644 --- a/src/gui/widgets/BasicBlockWidget.hxx +++ b/src/gui/widgets/BasicBlockWidget.hxx @@ -8,15 +8,12 @@ #include #include #include -#include #include "disassembler/Instruction.hxx" class Mainwindow; class CustomQGraphicsTextItem; - class BasicBlock; - class RenameFunctionEvent; class BasicBlockWidget : public QObject, public QGraphicsItem @@ -57,7 +54,7 @@ private: std::unique_ptr _widget; QTextTable* _table; BasicBlock* block; - std::list instructions; + std::vector instructions; Mainwindow* mainwindow; std::vector previous; BasicBlockWidget* next[2]; -- 2.39.5