Skip to content

Commit

Permalink
#220 avoid unnecessary getters in Bucket class
Browse files Browse the repository at this point in the history
  • Loading branch information
winfriedgerlach committed Nov 27, 2024
1 parent c72367f commit 0aa4c84
Showing 1 changed file with 10 additions and 13 deletions.
23 changes: 10 additions & 13 deletions src/main/java/com/ctc/wstx/util/SymbolTable.java
Original file line number Diff line number Diff line change
Expand Up @@ -638,15 +638,15 @@ private void rehash()
Bucket b = oldBuckets[i];
while (b != null) {
++count;
String symbol = b.getSymbol();
String symbol = b.mSymbol;
int index = calcHash(symbol) & mIndexMask;
if (mSymbols[index] == null) {
mSymbols[index] = symbol;
} else {
int bix = index >> 1;
mBuckets[bix] = new Bucket(symbol, mBuckets[bix]);
}
b = b.getNext();
b = b.mNext;
}
}

Expand Down Expand Up @@ -676,7 +676,7 @@ public double calcAvgSeek() {
while (b != null) {
count += cost;
++cost;
b = b.getNext();
b = b.mNext;
}
}

Expand All @@ -693,18 +693,15 @@ public double calcAvgSeek() {
* This class is a symbol table entry. Each entry acts as a node
* in a linked list.
*/
static final class Bucket {
private final String mSymbol;
private final Bucket mNext;
private static final class Bucket {
final String mSymbol;
final Bucket mNext;

public Bucket(String symbol, Bucket next) {
mSymbol = symbol;
mNext = next;
}

public String getSymbol() { return mSymbol; }
public Bucket getNext() { return mNext; }

public String find(char[] buf, int start, int len) {
String sym = mSymbol;
Bucket b = mNext;
Expand All @@ -724,8 +721,8 @@ public String find(char[] buf, int start, int len) {
if (b == null) {
break;
}
sym = b.getSymbol();
b = b.getNext();
sym = b.mSymbol;
b = b.mNext;
}
return null;
}
Expand All @@ -741,8 +738,8 @@ public String find(String str) {
if (b == null) {
break;
}
sym = b.getSymbol();
b = b.getNext();
sym = b.mSymbol;
b = b.mNext;
}
return null;
}
Expand Down

0 comments on commit 0aa4c84

Please sign in to comment.