Skip to content

Commit

Permalink
Merge pull request #137 from asztrikx/argtrace-speed-improvement
Browse files Browse the repository at this point in the history
improved ArgTrace's creation speed
  • Loading branch information
hajduakos committed Aug 31, 2021
2 parents e10eede + a8851d3 commit 20b4e49
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
2 changes: 1 addition & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ buildscript {

allprojects {
group = "hu.bme.mit.inf.theta"
version = "2.22.0"
version = "2.22.1"

apply(from = rootDir.resolve("gradle/shared-with-buildSrc/mirrors.gradle.kts"))
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ public final class ArgTrace<S extends State, A extends Action> implements Iterab
private final List<ArgEdge<S, A>> edges;

private ArgTrace(final ArgNode<S, A> node) {
// adding items to first index will lead to O(N^2) performance
final List<ArgNode<S, A>> nodeList = new ArrayList<>();
final List<ArgEdge<S, A>> edgeList = new ArrayList<>();

Expand All @@ -46,9 +47,14 @@ private ArgTrace(final ArgNode<S, A> node) {
while (running.getInEdge().isPresent()) {
final ArgEdge<S, A> inEdge = running.getInEdge().get();
running = inEdge.getSource();
edgeList.add(0, inEdge);
nodeList.add(0, running);
edgeList.add(inEdge);
nodeList.add(running);
}

// create the correct order by reversing O(N)
Collections.reverse(nodeList);
Collections.reverse(edgeList);

this.nodes = Collections.unmodifiableList(nodeList);
this.edges = Collections.unmodifiableList(edgeList);
}
Expand Down

0 comments on commit 20b4e49

Please sign in to comment.