@ -139,9 +139,8 @@ public class PackWriter {
private static final int PACK_VERSION_GENERATED = 2 ;
@SuppressWarnings ( "unchecked" )
private final List < ObjectToPack > objectsLists [ ] = new List [ Constants . OBJ_TAG + 1 ] ;
private final Block List< ObjectToPack > objectsLists [ ] = new Block List[ Constants . OBJ_TAG + 1 ] ;
{
objectsLists [ 0 ] = Collections . < ObjectToPack > emptyList ( ) ;
objectsLists [ Constants . OBJ_COMMIT ] = new BlockList < ObjectToPack > ( ) ;
objectsLists [ Constants . OBJ_TREE ] = new BlockList < ObjectToPack > ( ) ;
objectsLists [ Constants . OBJ_BLOB ] = new BlockList < ObjectToPack > ( ) ;
@ -412,8 +411,12 @@ public class PackWriter {
public long getObjectCount ( ) throws IOException {
if ( stats . totalObjects = = 0 ) {
long objCnt = 0 ;
for ( List < ObjectToPack > list : objectsLists )
objCnt + = list . size ( ) ;
objCnt + = objectsLists [ Constants . OBJ_COMMIT ] . size ( ) ;
objCnt + = objectsLists [ Constants . OBJ_TREE ] . size ( ) ;
objCnt + = objectsLists [ Constants . OBJ_BLOB ] . size ( ) ;
objCnt + = objectsLists [ Constants . OBJ_TAG ] . size ( ) ;
for ( CachedPack pack : cachedPacks )
objCnt + = pack . getObjectCount ( ) ;
return objCnt ;
@ -590,11 +593,16 @@ public class PackWriter {
private List < ObjectToPack > sortByName ( ) {
if ( sortedByName = = null ) {
int cnt = 0 ;
for ( List < ObjectToPack > list : objectsLists )
cnt + = list . size ( ) ;
cnt + = objectsLists [ Constants . OBJ_COMMIT ] . size ( ) ;
cnt + = objectsLists [ Constants . OBJ_TREE ] . size ( ) ;
cnt + = objectsLists [ Constants . OBJ_BLOB ] . size ( ) ;
cnt + = objectsLists [ Constants . OBJ_TAG ] . size ( ) ;
sortedByName = new BlockList < ObjectToPack > ( cnt ) ;
for ( List < ObjectToPack > list : objectsLists )
sortedByName . addAll ( list ) ;
sortedByName . addAll ( objectsLists [ Constants . OBJ_COMMIT ] ) ;
sortedByName . addAll ( objectsLists [ Constants . OBJ_TREE ] ) ;
sortedByName . addAll ( objectsLists [ Constants . OBJ_BLOB ] ) ;
sortedByName . addAll ( objectsLists [ Constants . OBJ_TAG ] ) ;
Collections . sort ( sortedByName ) ;
}
return sortedByName ;
@ -707,20 +715,29 @@ public class PackWriter {
private void searchForReuse ( ProgressMonitor monitor ) throws IOException {
int cnt = 0 ;
for ( List < ObjectToPack > list : objectsLists )
cnt + = list . size ( ) ;
cnt + = objectsLists [ Constants . OBJ_COMMIT ] . size ( ) ;
cnt + = objectsLists [ Constants . OBJ_TREE ] . size ( ) ;
cnt + = objectsLists [ Constants . OBJ_BLOB ] . size ( ) ;
cnt + = objectsLists [ Constants . OBJ_TAG ] . size ( ) ;
long start = System . currentTimeMillis ( ) ;
monitor . beginTask ( JGitText . get ( ) . searchForReuse , cnt ) ;
for ( List < ObjectToPack > list : objectsLists ) {
pruneCurrentObjectList = false ;
reuseSupport . selectObjectRepresentation ( this , monitor , list ) ;
if ( pruneCurrentObjectList )
pruneEdgesFromObjectList ( list ) ;
}
searchForReuse ( monitor , objectsLists [ Constants . OBJ_COMMIT ] ) ;
searchForReuse ( monitor , objectsLists [ Constants . OBJ_TREE ] ) ;
searchForReuse ( monitor , objectsLists [ Constants . OBJ_BLOB ] ) ;
searchForReuse ( monitor , objectsLists [ Constants . OBJ_TAG ] ) ;
monitor . endTask ( ) ;
stats . timeSearchingForReuse = System . currentTimeMillis ( ) - start ;
}
private void searchForReuse ( ProgressMonitor monitor , List < ObjectToPack > list )
throws IOException , MissingObjectException {
pruneCurrentObjectList = false ;
reuseSupport . selectObjectRepresentation ( this , monitor , list ) ;
if ( pruneCurrentObjectList )
pruneEdgesFromObjectList ( list ) ;
}
private void searchForDeltas ( ProgressMonitor monitor )
throws MissingObjectException , IncorrectObjectTypeException ,
IOException {
@ -1472,25 +1489,14 @@ public class PackWriter {
addObject ( object , 0 ) ;
}
private void addObject ( final RevObject object , final int pathHashCode )
throws IncorrectObjectTypeException {
private void addObject ( final RevObject object , final int pathHashCode ) {
final ObjectToPack otp ;
if ( reuseSupport ! = null )
otp = reuseSupport . newObjectToPack ( object ) ;
else
otp = new ObjectToPack ( object ) ;
otp . setPathHash ( pathHashCode ) ;
try {
objectsLists [ object . getType ( ) ] . add ( otp ) ;
} catch ( ArrayIndexOutOfBoundsException x ) {
throw new IncorrectObjectTypeException ( object ,
JGitText . get ( ) . incorrectObjectType_COMMITnorTREEnorBLOBnorTAG ) ;
} catch ( UnsupportedOperationException x ) {
// index pointing to "dummy" empty list
throw new IncorrectObjectTypeException ( object ,
JGitText . get ( ) . incorrectObjectType_COMMITnorTREEnorBLOBnorTAG ) ;
}
objectsLists [ object . getType ( ) ] . add ( otp ) ;
objectsMap . add ( otp ) ;
}