PackWriter#prepareBitmapIndex: add clarifying comments

New readers of #prepareBitmapIndex may be confused about the manual
memory management (hidden mutation and nulling out pointers).

Add two clarifying comments to help future readers.

Change-Id: I93cab1919066efda37e96c47667f6991f67e377e
This commit is contained in:
Anna Papitto 2022-12-19 16:20:14 -08:00 committed by Ivan Frade
parent fb3fd69584
commit 6722f25d56
1 changed files with 4 additions and 0 deletions

View File

@ -2371,10 +2371,14 @@ public boolean prepareBitmapIndex(ProgressMonitor pm) throws IOException {
int numCommits = objectsLists[OBJ_COMMIT].size();
List<ObjectToPack> byName = sortByName();
// Reset sortedByName before the array that it points to is mutated by
// PackBitmapIndexBuilder, to prevent other methods referencing the
// mutated array afterwards.
sortedByName = null;
objectsLists = null;
objectsMap = null;
writeBitmaps = new PackBitmapIndexBuilder(byName);
// Allow byName to be GC'd if JVM GC runs before the end of the method.
byName = null;
PackWriterBitmapPreparer bitmapPreparer = new PackWriterBitmapPreparer(