Browse Source

Refactor DfsReader selection of cached packs

Make the code more clear with a simple refactoring of the boolean
logic into a method that describes the condition we are looking
for on each pack file. A cached pack is possible if there exists
a tips collection, and the collection is non-empty.

Change-Id: I4ac42b0622b39d159a0f4f223e291c35c71f672c
stable-1.2
Shawn O. Pearce 13 years ago
parent
commit
4b84186b64
  1. 9
      org.eclipse.jgit/src/org/eclipse/jgit/storage/dfs/DfsReader.java

9
org.eclipse.jgit/src/org/eclipse/jgit/storage/dfs/DfsReader.java

@ -554,13 +554,16 @@ final class DfsReader extends ObjectReader implements ObjectReuseAsIs {
List<CachedPack> cached = new ArrayList<CachedPack>(packList.length); List<CachedPack> cached = new ArrayList<CachedPack>(packList.length);
for (DfsPackFile pack : packList) { for (DfsPackFile pack : packList) {
DfsPackDescription desc = pack.getPackDescription(); DfsPackDescription desc = pack.getPackDescription();
if (desc.getTips() == null || desc.getTips().isEmpty()) if (canBeCachedPack(desc))
continue; cached.add(new DfsCachedPack(pack));
cached.add(new DfsCachedPack(pack));
} }
return cached; return cached;
} }
private static boolean canBeCachedPack(DfsPackDescription desc) {
return desc.getTips() != null && !desc.getTips().isEmpty();
}
public void copyPackAsIs(PackOutputStream out, CachedPack pack, public void copyPackAsIs(PackOutputStream out, CachedPack pack,
boolean validate) throws IOException { boolean validate) throws IOException {
try { try {

Loading…
Cancel
Save