1 | VariableTableEntry[] oldTable = vTable;↵ | | 1 | SymbolEntry[] oldTable = symbolTable;↵
|
2 | int oldCapacity;↵ | | 2 | int oldCapacity;↵
|
3 | if ((oldCapacity = oldTable.length) >= MAXIMUM_CAPACITY) {↵ | | 3 | if ((oldCapacity = oldTable.length) >= MAXIMUM_CAPACITY) {↵
|
4 | return oldTable;↵ | | 4 | return oldTable;↵
|
5 | }↵ | | 5 | ↵
|
|
| | | 6 | }↵
|
| | | 7 | ↵
|
6 | int newCapacity = oldCapacity << 1;↵ | | 8 | int newCapacity = oldCapacity << 1;↵
|
7 | VariableTableEntry[] newTable = new VariableTableEntry[newCapacity];↵ | | 9 | SymbolEntry[] newTable = new SymbolEntry[newCapacity];↵
|
8 | vTableThreshold = (int)(newCapacity * LOAD_FACTOR);↵ | | 10 | threshold = (int)(newCapacity * ↵
|
| | | 11 | loadFactor);↵
|
9 | int sizeMask = newCapacity - 1;↵ | | 12 | int sizeMask = newCapacity - 1;↵
|
10 | VariableTableEntry e;↵ | | 13 | SymbolEntry e;↵
|
11 | for (int i = oldCapacity; --i >= 0; ) {↵ | | 14 | for (int i = oldCapacity; --i >= 0; ) {↵
|
12 | // We need to guarantee that any existing reads of old Map can↵ | | 15 | // We need to guarantee that any existing reads of old Map can↵
|
13 | // proceed. So we cannot yet null out each bin.↵ | | 16 | // proceed. So we cannot yet null out each bin.↵
|
14 | e = oldTable[i];↵ | | 17 | e = oldTable[i];↵
|
|
15 | if (e != null) {↵ | | 18 | if (e != null) {↵
|
16 | VariableTableEntry next = e.next;↵ | | 19 | SymbolEntry next = e.next;↵
|
17 | int idx = e.hash & sizeMask;↵ | | 20 | int idx = e.hash & sizeMask;↵
|
|
18 | // Single node on list↵ | | 21 | // Single node on list↵
|
19 | if (next == null)↵ | | 22 | if (next == null)↵
|
20 | newTable[idx] = e;↵ | | 23 | newTable[idx] = e;↵
|
|
21 | else {↵ | | 24 | else {↵
|
22 | // Reuse trailing consecutive sequence at same slot↵ | | 25 | // Reuse trailing consecutive sequence at same slot↵
|
23 | VariableTableEntry lastRun = e;↵ | | 26 | SymbolEntry lastRun = e;↵
|
24 | int lastIdx = idx;↵ | | 27 | int lastIdx = idx;↵
|
25 | for (VariableTableEntry last = next;↵ | | 28 | for (SymbolEntry last = next;↵
|
26 | last != null;↵ | | 29 | last != null;↵
|
27 | last = last.next) {↵ | | 30 | last = last.next) {↵
|
28 | int k = last.hash & sizeMask;↵ | | 31 | int k = last.hash & sizeMask;↵
|
29 | if (k != lastIdx) {↵ | | 32 | if (k != lastIdx) {↵
|
30 | lastIdx = k;↵ | | 33 | lastIdx = k;↵
|
31 | lastRun = last;↵ | | 34 | lastRun = last;↵
|
32 | }↵ | | 35 | ↵
|
| | | 36 | }↵
|
33 | }↵ | | 37 | ↵
|
| | | 38 | }↵
|
34 | newTable[lastIdx] = lastRun;↵ | | 39 | newTable[lastIdx] = lastRun;↵
|
|
35 | // Clone all remaining nodes↵ | | 40 | // Clone all remaining nodes↵
|
36 | for (VariableTableEntry p = e; p != lastRun; p = p.next) {↵ | | 41 | for (SymbolEntry p = e; p != lastRun; p = p.next) {↵
|
37 | int k = p.hash & sizeMask;↵ | | 42 | int k = p.hash & sizeMask;↵
|
38 | VariableTableEntry m = new VariableTable↵ | | 43 | SymbolEntry n = newTable[k];↵
|
39 | Entry(p.hash, p.name, p.value, newTable[k]);↵ | | 44 | newTable[k] = new SymbolEntry(p.hash, p.name, p.symbol, n);↵
|
40 | newTable[k] = m;↵ | | 45 | }↵
|
41 | }↵ | | 46 | }↵
|
42 | }↵ | | 47 | }↵
|
43 | }↵ | | 48 | }↵
|
44 | }↵ | | 49 | ↵
|
45 | vTable = newTable;↵ | | 50 | symbolTable = newTable;↵
|
46 | return newTable; | | 51 | return newTable;
|