Use expanded task if refreshing is not required When reusing defintions, use an already expanded one (and inform the Properties class of this so that it no longer expands it) whenever the task expansion results in a definition which does not depend on external factors and thus would always be the same anyway. Since definitions are mostly only reused for ChangeNodes, this is most effective when walking changes. In a sample walking ancestors use case, this caching and saves a small but measurable amount of the total time. In the case of a task.config which walks all dependencies for a change when run with status:open --no-limit --task--applicable the gain can be seen below. Before this change: 3m37s 3m34s 4m6s 6m23s 3m42s After this change: 8m7s 3m16s 3m26s 3m16s 3m21s Change-Id: I5892519583bc1b34fb9625b8b095e0af6d10c44f
diff --git a/src/main/java/com/googlesource/gerrit/plugins/task/TaskTree.java b/src/main/java/com/googlesource/gerrit/plugins/task/TaskTree.java index 40f0f2a..2f543bb 100644 --- a/src/main/java/com/googlesource/gerrit/plugins/task/TaskTree.java +++ b/src/main/java/com/googlesource/gerrit/plugins/task/TaskTree.java
@@ -328,7 +328,7 @@ } public Task getDefinition() { - return properties.origTask; + return properties.isTaskRefreshRequired() ? properties.origTask : task; } public boolean isChange() {