aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorShawn O. Pearce <spearce@spearce.org>2010-11-11 14:25:01 -0800
committerShawn O. Pearce <spearce@spearce.org>2010-11-12 11:57:02 -0800
commit918e6e20f04350557579add806f0deb2a59ba837 (patch)
tree6fa49f903cee9c1e309392b9e2a5ef78b5ceae8c
parent0e307a6afddbb564ea6c34b3766d749f80e4442a (diff)
downloadjgit-918e6e20f04350557579add806f0deb2a59ba837.tar.gz
jgit-918e6e20f04350557579add806f0deb2a59ba837.zip
SimilarityRenameDetector: Only attempt to index large files once
If a file fails to index the first time the loop encounters it, the file is likely to fail to index again on the next row. Rather than wasting a huge amount of CPU to index it again and fail, remember which destination files failed to index and skip over them on each subsequent row. Because this condition is very unlikely, avoid allocating the BitSet until its actually needed. This keeps the memory usage unaffected for the common case. Change-Id: I93509b28b61a9bba8f681a7b4df4c6127bca2a09 Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/diff/SimilarityRenameDetector.java10
1 files changed, 10 insertions, 0 deletions
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/diff/SimilarityRenameDetector.java b/org.eclipse.jgit/src/org/eclipse/jgit/diff/SimilarityRenameDetector.java
index 89e71e6661..bf1bbda63b 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/diff/SimilarityRenameDetector.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/diff/SimilarityRenameDetector.java
@@ -49,6 +49,7 @@ import static org.eclipse.jgit.diff.DiffEntry.Side.OLD;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
+import java.util.BitSet;
import java.util.List;
import org.eclipse.jgit.JGitText;
@@ -216,6 +217,7 @@ class SimilarityRenameDetector {
long[] srcSizes = new long[srcs.size()];
long[] dstSizes = new long[dsts.size()];
+ BitSet dstTooLarge = null;
// Init the size arrays to some value that indicates that we haven't
// calculated the size yet. Since sizes cannot be negative, -1 will work
@@ -255,6 +257,11 @@ class SimilarityRenameDetector {
continue;
}
+ if (dstTooLarge != null && dstTooLarge.get(dstIdx)) {
+ pm.update(1);
+ continue;
+ }
+
long srcSize = srcSizes[srcIdx];
if (srcSize < 0) {
srcSize = size(OLD, srcEnt);
@@ -279,6 +286,9 @@ class SimilarityRenameDetector {
try {
d = hash(NEW, dstEnt);
} catch (TableFullException tableFull) {
+ if (dstTooLarge == null)
+ dstTooLarge = new BitSet(dsts.size());
+ dstTooLarge.set(dstIdx);
tableOverflow = true;
pm.update(1);
continue;