@ -45,8 +45,7 @@ package org.eclipse.jgit.internal.storage.dfs;
import static org.eclipse.jgit.internal.storage.pack.PackExt.PACK ;
import java.util.HashMap ;
import java.util.Map ;
import java.util.Arrays ;
import org.eclipse.jgit.internal.storage.dfs.DfsObjDatabase.PackSource ;
import org.eclipse.jgit.internal.storage.pack.PackExt ;
@ -62,25 +61,15 @@ import org.eclipse.jgit.storage.pack.PackStatistics;
* /
public class DfsPackDescription implements Comparable < DfsPackDescription > {
private final DfsRepositoryDescription repoDesc ;
private final String packName ;
private PackSource packSource ;
private long lastModified ;
private final Map < PackExt , Long > sizeMap ;
private long [ ] sizeMap ;
private long objectCount ;
private long deltaCount ;
private PackStatistics stats ;
private int extensions ;
private int indexVersion ;
private long estimatedPackSize ;
/ * *
@ -102,7 +91,7 @@ public class DfsPackDescription implements Comparable<DfsPackDescription> {
this . repoDesc = repoDesc ;
int dot = name . lastIndexOf ( '.' ) ;
this . packName = ( dot < 0 ) ? name : name . substring ( 0 , dot ) ;
this . sizeMap = new HashMap < > ( PackExt . values ( ) . length * 2 ) ;
this . sizeMap = new long [ PackExt . values ( ) . length ] ;
}
/** @return description of the repository. */
@ -186,7 +175,11 @@ public class DfsPackDescription implements Comparable<DfsPackDescription> {
* @return { @code this }
* /
public DfsPackDescription setFileSize ( PackExt ext , long bytes ) {
sizeMap . put ( ext , Long . valueOf ( Math . max ( 0 , bytes ) ) ) ;
int i = ext . getPosition ( ) ;
if ( i > = sizeMap . length ) {
sizeMap = Arrays . copyOf ( sizeMap , i + 1 ) ;
}
sizeMap [ i ] = Math . max ( 0 , bytes ) ;
return this ;
}
@ -196,8 +189,8 @@ public class DfsPackDescription implements Comparable<DfsPackDescription> {
* @return size of the file , in bytes . If 0 the file size is not yet known .
* /
public long getFileSize ( PackExt ext ) {
Long size = sizeMap . get ( ext ) ;
return size = = null ? 0 : size . longValue ( ) ;
int i = ext . getPosition ( ) ;
return i < sizeMap . length ? sizeMap [ i ] : 0 ;
}
/ * *