Skip to content

Commit

Permalink
Merge branch 'master' into feature/FasterXML#220-do-not-use-Arrays.co…
Browse files Browse the repository at this point in the history
…pyOf
  • Loading branch information
cowtowncoder authored Nov 27, 2024
2 parents 556455e + 012a512 commit d2319fe
Showing 1 changed file with 16 additions and 19 deletions.
35 changes: 16 additions & 19 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.symbol;
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.next;
}
}

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

Expand All @@ -693,21 +693,18 @@ 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 {
public final String symbol;
public final Bucket next;

public Bucket(String symbol, Bucket next) {
mSymbol = symbol;
mNext = next;
this.symbol = symbol;
this.next = 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;
String sym = symbol;
Bucket b = next;

while (true) { // Inlined equality comparison:
if (sym.length() == len) {
Expand All @@ -724,15 +721,15 @@ public String find(char[] buf, int start, int len) {
if (b == null) {
break;
}
sym = b.getSymbol();
b = b.getNext();
sym = b.symbol;
b = b.next;
}
return null;
}

public String find(String str) {
String sym = mSymbol;
Bucket b = mNext;
String sym = symbol;
Bucket b = next;

while (true) {
if (sym.equals(str)) {
Expand All @@ -741,8 +738,8 @@ public String find(String str) {
if (b == null) {
break;
}
sym = b.getSymbol();
b = b.getNext();
sym = b.symbol;
b = b.next;
}
return null;
}
Expand Down

0 comments on commit d2319fe

Please sign in to comment.