diff src/org/tmatesoft/hg/internal/RevlogStream.java @ 258:e5776067b3b8

Reduce number of objects instantiated on revlog read
author Artem Tikhomirov <tikhomirov.artem@gmail.com>
date Tue, 16 Aug 2011 22:08:15 +0200
parents 0e01f9182e16
children 31f67be94e71
line wrap: on
line diff
--- a/src/org/tmatesoft/hg/internal/RevlogStream.java	Tue Aug 16 22:07:16 2011 +0200
+++ b/src/org/tmatesoft/hg/internal/RevlogStream.java	Tue Aug 16 22:08:15 2011 +0200
@@ -22,7 +22,6 @@
 import java.io.File;
 import java.io.IOException;
 import java.util.ArrayList;
-import java.util.LinkedList;
 import java.util.List;
 
 import org.tmatesoft.hg.core.HgBadStateException;
@@ -394,6 +393,8 @@
 			}
 			
 			daIndex.seek(getIndexOffsetInt(i));
+			//
+			final ArrayList<PatchRecord> patches = new ArrayList<PatchRecord>();
 			
 			for (; i <= end; i++ ) {
 				if (inline && needData) {
@@ -443,7 +444,6 @@
 					// XXX 
 					if (patchToPrevious) {
 						// this is a patch
-						LinkedList<PatchRecord> patches = new LinkedList<PatchRecord>();
 						while (!userDataAccess.isEmpty()) {
 							PatchRecord pr = PatchRecord.read(userDataAccess);
 //							System.out.printf("PatchRecord:%d %d %d\n", pr.start, pr.end, pr.len);
@@ -452,6 +452,7 @@
 						userDataAccess.done();
 						//
 						byte[] userData = apply(lastUserData, actualLen, patches);
+						patches.clear();
 						userDataAccess = new ByteArrayDataAccess(userData);
 					}
 				} else {