summaryrefslogtreecommitdiff
path: root/functiongraphblock.cpp
diff options
context:
space:
mode:
authorRusty Wagner <rusty@vector35.com>2016-10-10 18:24:38 -0400
committerRusty Wagner <rusty@vector35.com>2016-10-10 18:24:38 -0400
commit98d187d9d86506ea915731266b8faaaa2dc0c9d6 (patch)
treefa1ee82d342c12ed5d42e7caf9397312edf7cf63 /functiongraphblock.cpp
parent4598adb7ae961e69fb6ed3e594c0244c49eef511 (diff)
parent55ac7a184b7956c0c2e2ca41d512e7c4a81267d9 (diff)
Merge commit '55ac7a184b7956c0c2e2ca41d512e7c4a81267d9'
Diffstat (limited to 'functiongraphblock.cpp')
-rw-r--r--functiongraphblock.cpp26
1 files changed, 22 insertions, 4 deletions
diff --git a/functiongraphblock.cpp b/functiongraphblock.cpp
index af330497..47261453 100644
--- a/functiongraphblock.cpp
+++ b/functiongraphblock.cpp
@@ -27,6 +27,14 @@ using namespace std;
FunctionGraphBlock::FunctionGraphBlock(BNFunctionGraphBlock* block)
{
m_object = block;
+ m_cachedLinesValid = false;
+ m_cachedEdgesValid = false;
+}
+
+
+Ref<BasicBlock> FunctionGraphBlock::GetBasicBlock() const
+{
+ return new BasicBlock(BNGetFunctionGraphBasicBlock(m_object));
}
@@ -72,8 +80,11 @@ int FunctionGraphBlock::GetHeight() const
}
-vector<DisassemblyTextLine> FunctionGraphBlock::GetLines() const
+const vector<DisassemblyTextLine>& FunctionGraphBlock::GetLines()
{
+ if (m_cachedLinesValid)
+ return m_cachedLines;
+
size_t count;
BNDisassemblyTextLine* lines = BNGetFunctionGraphBlockLines(m_object, &count);
@@ -96,12 +107,17 @@ vector<DisassemblyTextLine> FunctionGraphBlock::GetLines() const
}
BNFreeDisassemblyTextLines(lines, count);
- return result;
+ m_cachedLines = result;
+ m_cachedLinesValid = true;
+ return m_cachedLines;
}
-vector<FunctionGraphEdge> FunctionGraphBlock::GetOutgoingEdges() const
+const vector<FunctionGraphEdge>& FunctionGraphBlock::GetOutgoingEdges()
{
+ if (m_cachedEdgesValid)
+ return m_cachedEdges;
+
size_t count;
BNFunctionGraphEdge* edges = BNGetFunctionGraphBlockOutgoingEdges(m_object, &count);
@@ -117,5 +133,7 @@ vector<FunctionGraphEdge> FunctionGraphBlock::GetOutgoingEdges() const
}
BNFreeFunctionGraphBlockOutgoingEdgeList(edges, count);
- return result;
+ m_cachedEdges = result;
+ m_cachedEdgesValid = true;
+ return m_cachedEdges;
}