Browse Source

Merge "Use int[] rather than IntList for RawText hashes"

stable-0.9
Christian Halstrick 14 years ago committed by Code Review
parent
commit
f7f7c55bca
  1. 12
      org.eclipse.jgit/src/org/eclipse/jgit/diff/RawText.java
  2. 2
      org.eclipse.jgit/src/org/eclipse/jgit/diff/RawTextIgnoreAllWhitespace.java
  3. 2
      org.eclipse.jgit/src/org/eclipse/jgit/diff/RawTextIgnoreLeadingWhitespace.java
  4. 2
      org.eclipse.jgit/src/org/eclipse/jgit/diff/RawTextIgnoreTrailingWhitespace.java
  5. 2
      org.eclipse.jgit/src/org/eclipse/jgit/diff/RawTextIgnoreWhitespaceChange.java

12
org.eclipse.jgit/src/org/eclipse/jgit/diff/RawText.java

@ -95,7 +95,7 @@ public class RawText implements Sequence {
protected final IntList lines; protected final IntList lines;
/** Hash code for each line, for fast equality elimination. */ /** Hash code for each line, for fast equality elimination. */
protected final IntList hashes; protected final int[] hashes;
/** /**
* Create a new sequence from an existing content byte array. * Create a new sequence from an existing content byte array.
@ -140,7 +140,7 @@ public class RawText implements Sequence {
private static boolean equals(final RawText a, final int ai, private static boolean equals(final RawText a, final int ai,
final RawText b, final int bi) { final RawText b, final int bi) {
if (a.hashes.get(ai) != b.hashes.get(bi)) if (a.hashes[ai] != b.hashes[bi])
return false; return false;
int as = a.lines.get(ai); int as = a.lines.get(ai);
@ -197,15 +197,13 @@ public class RawText implements Sequence {
return content[end - 1] != '\n'; return content[end - 1] != '\n';
} }
private IntList computeHashes() { private int[] computeHashes() {
final IntList r = new IntList(lines.size()); final int[] r = new int[lines.size()];
r.add(0);
for (int lno = 1; lno < lines.size() - 1; lno++) { for (int lno = 1; lno < lines.size() - 1; lno++) {
final int ptr = lines.get(lno); final int ptr = lines.get(lno);
final int end = lines.get(lno + 1); final int end = lines.get(lno + 1);
r.add(hashLine(content, ptr, end)); r[lno] = hashLine(content, ptr, end);
} }
r.add(0);
return r; return r;
} }

2
org.eclipse.jgit/src/org/eclipse/jgit/diff/RawTextIgnoreAllWhitespace.java

@ -79,7 +79,7 @@ public class RawTextIgnoreAllWhitespace extends RawText {
private static boolean equals(final RawText a, final int ai, private static boolean equals(final RawText a, final int ai,
final RawText b, final int bi) { final RawText b, final int bi) {
if (a.hashes.get(ai) != b.hashes.get(bi)) if (a.hashes[ai] != b.hashes[bi])
return false; return false;
int as = a.lines.get(ai); int as = a.lines.get(ai);

2
org.eclipse.jgit/src/org/eclipse/jgit/diff/RawTextIgnoreLeadingWhitespace.java

@ -78,7 +78,7 @@ public class RawTextIgnoreLeadingWhitespace extends RawText {
private static boolean equals(final RawText a, final int ai, private static boolean equals(final RawText a, final int ai,
final RawText b, final int bi) { final RawText b, final int bi) {
if (a.hashes.get(ai) != b.hashes.get(bi)) if (a.hashes[ai] != b.hashes[bi])
return false; return false;
int as = a.lines.get(ai); int as = a.lines.get(ai);

2
org.eclipse.jgit/src/org/eclipse/jgit/diff/RawTextIgnoreTrailingWhitespace.java

@ -78,7 +78,7 @@ public class RawTextIgnoreTrailingWhitespace extends RawText {
private static boolean equals(final RawText a, final int ai, private static boolean equals(final RawText a, final int ai,
final RawText b, final int bi) { final RawText b, final int bi) {
if (a.hashes.get(ai) != b.hashes.get(bi)) if (a.hashes[ai] != b.hashes[bi])
return false; return false;
int as = a.lines.get(ai); int as = a.lines.get(ai);

2
org.eclipse.jgit/src/org/eclipse/jgit/diff/RawTextIgnoreWhitespaceChange.java

@ -81,7 +81,7 @@ public class RawTextIgnoreWhitespaceChange extends RawText {
private static boolean equals(final RawText a, final int ai, private static boolean equals(final RawText a, final int ai,
final RawText b, final int bi) { final RawText b, final int bi) {
if (a.hashes.get(ai) != b.hashes.get(bi)) if (a.hashes[ai] != b.hashes[bi])
return false; return false;
int as = a.lines.get(ai); int as = a.lines.get(ai);

Loading…
Cancel
Save