From f85cf3e84b2cfeb88739b3a8f9bd87ae51d22c1f Mon Sep 17 00:00:00 2001 From: kohsuke Date: Mon, 7 Apr 2008 22:14:38 +0000 Subject: [PATCH] Bit of performance optimization. git-svn-id: https://hudson.dev.java.net/svn/hudson/trunk/hudson/main@8355 71c3de6d-444a-0410-be80-ed276b4c234a --- core/src/main/java/hudson/model/AbstractBuild.java | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/core/src/main/java/hudson/model/AbstractBuild.java b/core/src/main/java/hudson/model/AbstractBuild.java index e15b23a98c..aed3ca9399 100644 --- a/core/src/main/java/hudson/model/AbstractBuild.java +++ b/core/src/main/java/hudson/model/AbstractBuild.java @@ -411,12 +411,23 @@ public abstract class AbstractBuild

,R extends Abs public String getWhyKeepLog() { // if any of the downstream project is configured with 'keep dependency component', // we need to keep this log + OUTER: for (AbstractProject p : getParent().getDownstreamProjects()) { if(!p.isKeepDependencies()) continue; + AbstractBuild fb = p.getFirstBuild(); + if(fb==null) continue; // no active record + + // is there any active build that depends on us? for(int i : getDownstreamRelationship(p).listNumbersReverse()) { + // TODO: this is essentially a "find intersection between two sparse sequences" + // and we should be able to do much better. + + if(i b = p.getBuildByNumber(i); - if(b!=null && b.isKeepLog()) + if(b!=null) return Messages.AbstractBuild_KeptBecause(b); } }