diff options
Diffstat (limited to 'functiongraphblock.cpp')
| -rw-r--r-- | functiongraphblock.cpp | 20 |
1 files changed, 16 insertions, 4 deletions
diff --git a/functiongraphblock.cpp b/functiongraphblock.cpp index af330497..436339f6 100644 --- a/functiongraphblock.cpp +++ b/functiongraphblock.cpp @@ -27,6 +27,8 @@ using namespace std; FunctionGraphBlock::FunctionGraphBlock(BNFunctionGraphBlock* block) { m_object = block; + m_cachedLinesValid = false; + m_cachedEdgesValid = false; } @@ -72,8 +74,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 +101,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 +127,7 @@ vector<FunctionGraphEdge> FunctionGraphBlock::GetOutgoingEdges() const } BNFreeFunctionGraphBlockOutgoingEdgeList(edges, count); - return result; + m_cachedEdges = result; + m_cachedEdgesValid = true; + return m_cachedEdges; } |
