ソースを参照

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>
tags/v0.10.1
Shawn O. Pearce 13年前
コミット
05653bda04
1個のファイルの変更4行の追加9行の削除
  1. 4
    9
      org.eclipse.jgit/src/org/eclipse/jgit/diff/SimilarityRenameDetector.java

+ 4
- 9
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;
}


読み込み中…
キャンセル
保存