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

This commit is contained in:
Christian Halstrick 2010-09-02 07:46:50 -04:00 committed by Code Review
commit f7f7c55bca
5 changed files with 9 additions and 11 deletions

View File

@ -95,7 +95,7 @@ public RawText create(byte[] input) {
protected final IntList lines;
/** 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.
@ -140,7 +140,7 @@ public boolean equals(final int i, final Sequence other, final int j) {
private static boolean equals(final RawText a, final int ai,
final RawText b, final int bi) {
if (a.hashes.get(ai) != b.hashes.get(bi))
if (a.hashes[ai] != b.hashes[bi])
return false;
int as = a.lines.get(ai);
@ -197,15 +197,13 @@ public boolean isMissingNewlineAtEnd() {
return content[end - 1] != '\n';
}
private IntList computeHashes() {
final IntList r = new IntList(lines.size());
r.add(0);
private int[] computeHashes() {
final int[] r = new int[lines.size()];
for (int lno = 1; lno < lines.size() - 1; lno++) {
final int ptr = lines.get(lno);
final int end = lines.get(lno + 1);
r.add(hashLine(content, ptr, end));
r[lno] = hashLine(content, ptr, end);
}
r.add(0);
return r;
}

View File

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

View File

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

View File

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

View File

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