aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorShawn O. Pearce <spearce@spearce.org>2010-11-11 14:43:22 -0800
committerShawn O. Pearce <spearce@spearce.org>2010-11-12 11:57:02 -0800
commit05653bda04a8199fceacd7f8b26c8af4dd8a8f3a (patch)
treef6848c502e08471839ec79b1fcf3572929e83b37
parent68baa3097e721cec42e6a52b72e7a2fe3ea57b18 (diff)
downloadjgit-05653bda04a8199fceacd7f8b26c8af4dd8a8f3a.tar.gz
jgit-05653bda04a8199fceacd7f8b26c8af4dd8a8f3a.zip
SimilarityRenameDetector: Initialize sizes to 0
Setting the array elements to -1 is more expensive than relying on the allocator to zero the array for us first. Shifting the code to always add 1 to the size (so an empty file is actually 1 byte long) allows us to detect an unloaded size by comparing to 0, thus saving the array fill calls. Change-Id: Iad859e910655675b53ba70de8e6fceaef7cfcdd1 Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/diff/SimilarityRenameDetector.java13
1 files changed, 4 insertions, 9 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 f47caf97f5..3a9847545b 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/diff/SimilarityRenameDetector.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/diff/SimilarityRenameDetector.java
@@ -219,11 +219,6 @@ class SimilarityRenameDetector {
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
- Arrays.fill(srcSizes, -1);
- Arrays.fill(dstSizes, -1);
-
// Consider each pair of files, if the score is above the minimum
// threshold we need record that scoring in the matrix so we can
// later find the best matches.
@@ -257,14 +252,14 @@ class SimilarityRenameDetector {
}
long srcSize = srcSizes[srcIdx];
- if (srcSize < 0) {
- srcSize = size(OLD, srcEnt);
+ if (srcSize == 0) {
+ srcSize = size(OLD, srcEnt) + 1;
srcSizes[srcIdx] = srcSize;
}
long dstSize = dstSizes[dstIdx];
- if (dstSize < 0) {
- dstSize = size(NEW, dstEnt);
+ if (dstSize == 0) {
+ dstSize = size(NEW, dstEnt) + 1;
dstSizes[dstIdx] = dstSize;
}