Browse Source

DfsObjDatabase: Add lazy last modified method to PackList

Change-Id: Id045f162fa584ea14da29a9df58a42c53a78dc15
stable-4.5
Dave Borowitz 8 years ago
parent
commit
ecb2aa0503
  1. 14
      org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/dfs/DfsObjDatabase.java

14
org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/dfs/DfsObjDatabase.java

@ -495,10 +495,24 @@ public abstract class DfsObjDatabase extends ObjectDatabase {
/** All known packs, sorted. */ /** All known packs, sorted. */
public final DfsPackFile[] packs; public final DfsPackFile[] packs;
private long lastModified = -1;
PackList(DfsPackFile[] packs) { PackList(DfsPackFile[] packs) {
this.packs = packs; this.packs = packs;
} }
/** @return last modified time of all packs, in milliseconds. */
public long getLastModified() {
if (lastModified < 0) {
long max = 0;
for (DfsPackFile pack : packs) {
max = Math.max(max, pack.getPackDescription().getLastModified());
}
lastModified = max;
}
return lastModified;
}
abstract boolean dirty(); abstract boolean dirty();
/** /**

Loading…
Cancel
Save