# HG changeset patch
# User Artem Tikhomirov <tikhomirov.artem@gmail.com>
# Date 1366999457 -7200
# Node ID a52f4cc56f9c3e7fb940370100c136c28aa43ef0
# Parent  73c20c648c1ffa1d4bd2bf37b15bb8c5a03422b8
Minimize vectors re-allocating when merging patches

diff -r 73c20c648c1f -r a52f4cc56f9c src/org/tmatesoft/hg/internal/Patch.java
--- a/src/org/tmatesoft/hg/internal/Patch.java	Fri Apr 26 18:38:41 2013 +0200
+++ b/src/org/tmatesoft/hg/internal/Patch.java	Fri Apr 26 20:04:17 2013 +0200
@@ -68,14 +68,18 @@
 	}
 	
 	public Patch() {
-		this(false);
+		this(16, false);
+	}
+	
+	public Patch(boolean normalizeOnChange) {
+		this(16, normalizeOnChange);
 	}
 
-	public Patch(boolean normalizeOnChange) {
+	public Patch(int sizeHint, boolean normalizeOnChange) {
 		shallNormalize = normalizeOnChange;
-		starts = new IntVector();
-		ends = new IntVector();
-		data = new ArrayList<byte[]>();
+		starts = new IntVector(sizeHint, -1);
+		ends = new IntVector(sizeHint, -1);
+		data = new ArrayList<byte[]>(sizeHint);
 	}
 	
 	public String toString() {
@@ -227,7 +231,7 @@
 	 * Modify this patch with subsequent patch 
 	 */
 	public /*SHALL BE PUBLIC ONCE TESTING ENDS*/ Patch apply(Patch another) {
-		Patch r = new Patch(shallNormalize);
+		Patch r = new Patch(count() + another.count() * 2, shallNormalize);
 		int p1TotalAppliedDelta = 0; // value to add to start and end indexes of the older patch to get their values as if
 		// in the patched text, iow, directly comparable with respective indexes from the newer patch.
 		int p1EntryStart = 0, p1EntryEnd = 0, p1EntryLen = 0;