logic: Improved graph and code view performance
* added sql index for component_access * improved policy for expanded code files * reduced amount of initially expanded code files * faster DummyEdge creation * faster DummyNode search by token id * switched GraphController DummyNodes and DummyEdges to shared_ptr for memory safety
This commit is contained in:
@@ -130,19 +130,20 @@ BucketGrid::BucketGrid(Vec2i viewSize)
|
||||
m_buckets[0][0] = Bucket(0, 0);
|
||||
}
|
||||
|
||||
void BucketGrid::createBuckets(std::vector<DummyNode>& nodes, const std::vector<DummyEdge>& edges)
|
||||
{
|
||||
void BucketGrid::createBuckets(
|
||||
std::vector<std::shared_ptr<DummyNode>>& nodes, const std::vector<std::shared_ptr<DummyEdge>>& edges
|
||||
){
|
||||
if (!nodes.size())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
bool activeNodeAdded = false;
|
||||
for (DummyNode& node : nodes)
|
||||
for (std::shared_ptr<DummyNode> node : nodes)
|
||||
{
|
||||
if (node.hasActiveSubNode() || !edges.size())
|
||||
if (node->hasActiveSubNode() || !edges.size())
|
||||
{
|
||||
addNode(&node);
|
||||
addNode(node.get());
|
||||
activeNodeAdded = true;
|
||||
}
|
||||
}
|
||||
@@ -154,13 +155,13 @@ void BucketGrid::createBuckets(std::vector<DummyNode>& nodes, const std::vector<
|
||||
|
||||
if (!activeNodeAdded)
|
||||
{
|
||||
addNode(&nodes[0]);
|
||||
addNode(nodes[0].get());
|
||||
}
|
||||
|
||||
std::vector<const DummyEdge*> remainingEdges;
|
||||
for (const DummyEdge& edge : edges)
|
||||
for (std::shared_ptr<DummyEdge> edge : edges)
|
||||
{
|
||||
remainingEdges.push_back(&edge);
|
||||
remainingEdges.push_back(edge.get());
|
||||
}
|
||||
|
||||
size_t i = 0;
|
||||
@@ -265,18 +266,19 @@ void BucketGrid::layoutBuckets()
|
||||
}
|
||||
}
|
||||
|
||||
DummyNode* BucketGrid::findTopMostDummyNodeRecursive(std::vector<DummyNode>& nodes, Id tokenId, DummyNode* top)
|
||||
{
|
||||
for (DummyNode& node : nodes)
|
||||
DummyNode* BucketGrid::findTopMostDummyNodeRecursive(
|
||||
std::vector<std::shared_ptr<DummyNode>>& nodes, Id tokenId, DummyNode* top
|
||||
){
|
||||
for (std::shared_ptr<DummyNode> node : nodes)
|
||||
{
|
||||
DummyNode* t = (top ? top : &node);
|
||||
DummyNode* t = (top ? top : node.get());
|
||||
|
||||
if (node.visible && node.tokenId == tokenId)
|
||||
if (node->visible && node->tokenId == tokenId)
|
||||
{
|
||||
return t;
|
||||
}
|
||||
|
||||
DummyNode* result = findTopMostDummyNodeRecursive(node.subNodes, tokenId, t);
|
||||
DummyNode* result = findTopMostDummyNodeRecursive(node->subNodes, tokenId, t);
|
||||
if (result != nullptr)
|
||||
{
|
||||
return result;
|
||||
|
||||
@@ -43,12 +43,15 @@ class BucketGrid
|
||||
{
|
||||
public:
|
||||
BucketGrid(Vec2i viewSize);
|
||||
void createBuckets(std::vector<DummyNode>& nodes, const std::vector<DummyEdge>& edges);
|
||||
void createBuckets(
|
||||
std::vector<std::shared_ptr<DummyNode>>& nodes,
|
||||
const std::vector<std::shared_ptr<DummyEdge>>& edges);
|
||||
void sortBuckets();
|
||||
void layoutBuckets();
|
||||
|
||||
private:
|
||||
DummyNode* findTopMostDummyNodeRecursive(std::vector<DummyNode>& nodes, Id tokenId, DummyNode* top = nullptr);
|
||||
DummyNode* findTopMostDummyNodeRecursive(
|
||||
std::vector<std::shared_ptr<DummyNode>>& nodes, Id tokenId, DummyNode* top = nullptr);
|
||||
|
||||
void addNode(DummyNode* node);
|
||||
bool addNode(DummyNode* owner, DummyNode* target, bool horizontal);
|
||||
|
||||
@@ -73,9 +73,9 @@ public:
|
||||
|
||||
bool hasVisibleSubNode() const
|
||||
{
|
||||
for (const DummyNode& node : subNodes)
|
||||
for (std::shared_ptr<DummyNode> node : subNodes)
|
||||
{
|
||||
if (node.visible)
|
||||
if (node->visible)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
@@ -91,9 +91,9 @@ public:
|
||||
return true;
|
||||
}
|
||||
|
||||
for (const DummyNode& node : subNodes)
|
||||
for (std::shared_ptr<DummyNode> node : subNodes)
|
||||
{
|
||||
if (node.hasActiveSubNode())
|
||||
if (node->hasActiveSubNode())
|
||||
{
|
||||
return true;
|
||||
}
|
||||
@@ -111,9 +111,9 @@ public:
|
||||
count += 1;
|
||||
}
|
||||
|
||||
for (const DummyNode& node : subNodes)
|
||||
for (std::shared_ptr<DummyNode> node : subNodes)
|
||||
{
|
||||
count += node.getActiveSubNodeCount();
|
||||
count += node->getActiveSubNodeCount();
|
||||
}
|
||||
|
||||
return count;
|
||||
@@ -126,9 +126,9 @@ public:
|
||||
return true;
|
||||
}
|
||||
|
||||
for (const DummyNode& node : subNodes)
|
||||
for (std::shared_ptr<DummyNode> node : subNodes)
|
||||
{
|
||||
if (node.hasConnectedSubNode())
|
||||
if (node->hasConnectedSubNode())
|
||||
{
|
||||
return true;
|
||||
}
|
||||
@@ -146,9 +146,9 @@ public:
|
||||
count += 1;
|
||||
}
|
||||
|
||||
for (const DummyNode& node : subNodes)
|
||||
for (std::shared_ptr<DummyNode> node : subNodes)
|
||||
{
|
||||
count += node.getConnectedSubNodeCount();
|
||||
count += node->getConnectedSubNodeCount();
|
||||
}
|
||||
|
||||
return count;
|
||||
@@ -163,9 +163,9 @@ public:
|
||||
nodes.push_back(this);
|
||||
}
|
||||
|
||||
for (const DummyNode& node : subNodes)
|
||||
for (std::shared_ptr<DummyNode> node : subNodes)
|
||||
{
|
||||
utility::append(nodes, node.getConnectedSubNodes());
|
||||
utility::append(nodes, node->getConnectedSubNodes());
|
||||
}
|
||||
|
||||
return nodes;
|
||||
@@ -174,9 +174,9 @@ public:
|
||||
std::vector<const DummyNode*> getAllBundledNodes() const
|
||||
{
|
||||
std::vector<const DummyNode*> nodes;
|
||||
for (const DummyNode& node : bundledNodes)
|
||||
for (std::shared_ptr<DummyNode> node : bundledNodes)
|
||||
{
|
||||
utility::append(nodes, node.getConnectedSubNodes());
|
||||
utility::append(nodes, node->getConnectedSubNodes());
|
||||
}
|
||||
return nodes;
|
||||
}
|
||||
@@ -200,7 +200,7 @@ public:
|
||||
Id topLevelAncestorId;
|
||||
Id tokenId;
|
||||
|
||||
std::vector<DummyNode> subNodes;
|
||||
std::vector<std::shared_ptr<DummyNode>> subNodes;
|
||||
|
||||
// GraphNode
|
||||
const Node* data;
|
||||
@@ -221,7 +221,7 @@ public:
|
||||
BundleInfo bundleInfo;
|
||||
|
||||
// BundleNode
|
||||
std::vector<DummyNode> bundledNodes;
|
||||
std::vector<std::shared_ptr<DummyNode>> bundledNodes;
|
||||
size_t bundledNodeCount;
|
||||
};
|
||||
|
||||
|
||||
@@ -170,7 +170,7 @@ MatrixDynamicBase<int> GraphLayouter::buildLaplacianMatrix(
|
||||
{
|
||||
for(unsigned int i = 0; i < remainingNodes.front().subNodes.size(); i++)
|
||||
{
|
||||
remainingNodes.push(remainingNodes.front().subNodes[i]);
|
||||
remainingNodes.push(*remainingNodes.front().subNodes[i].get());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user