diff options
| author | Rusty Wagner <rusty@vector35.com> | 2016-08-31 17:21:53 -0400 |
|---|---|---|
| committer | Rusty Wagner <rusty@vector35.com> | 2016-08-31 17:22:29 -0400 |
| commit | c910aa5a42fb789225bb58c990d077d39da9b4ce (patch) | |
| tree | 45222fe184d2f0a64b4801fde05b72454cf3aa05 /functiongraphblock.cpp | |
| parent | 548b906badf83e500551522a87242fefbc582d2c (diff) | |
Cache lines on API side to avoid UI hangs with large basic blocks
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; } |
