SchemaStrings.java
1.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
/*
* Decompiled with CFR 0_118.
*/
package com.adobe.xfa;
public class SchemaStrings {
private final String[] keys;
private final int[] values;
private int size;
private final int hashMask;
public SchemaStrings(int size) {
int capacity = SchemaStrings.calculateTableSize(size);
this.keys = new String[capacity];
this.values = new int[capacity];
this.hashMask = capacity - 1;
}
private static int calculateTableSize(int capacity) {
int n;
assert (capacity > 0);
capacity = capacity * 10 / 8;
for (n = 16; capacity > n; n *= 2) {
}
return n;
}
public void put(String sStr, int eTag) {
int capacity = this.keys.length;
assert (this.size < capacity - 1);
int position = sStr.hashCode() & this.hashMask;
do {
assert (!sStr.equals(this.keys[position]));
if (this.keys[position] == null) {
this.keys[position] = sStr;
this.values[position] = eTag;
++this.size;
return;
}
if (++position != capacity) continue;
position = 0;
} while (true);
}
public int getInt(String sStr) {
int capacity = this.keys.length;
int position = sStr.hashCode() & this.hashMask;
String key;
while ((key = this.keys[position]) != null) {
if (key.equals(sStr)) {
return this.values[position];
}
if (++position != capacity) continue;
position = 0;
}
return -1;
}
}