Patch #6540 » NamePool_locking_behavior_improvements.patch
src/main/java/net/sf/saxon/om/NamePool.java (revision 497a9f0a7549279d890f1f49cd5002320869bf9f) → src/main/java/net/sf/saxon/om/NamePool.java (date 1726698522394) | ||
---|---|---|
private final ConcurrentHashMap<NamespaceUri, String> suggestedPrefixes = new ConcurrentHashMap<>();
|
||
private final Object fingerprintGuard = new Object();
|
||
... | ... | |
* for the same name with a prefix equal to "".
|
||
*/
|
||
|
||
public synchronized int allocateFingerprint(NamespaceUri uri, String local) {
|
||
if (NamespaceUri.isReserved(uri) || NamespaceUri.SAXON.equals(uri)) {
|
||
public int allocateFingerprint(NamespaceUri uri, String local) {
|
||
if (!uri.equals(NamespaceUri.NULL) && (NamespaceUri.isReserved(uri) || NamespaceUri.SAXON.equals(uri))) {
|
||
int fp = StandardNames.getFingerprint(uri, local);
|
||
if (fp != -1) {
|
||
return fp;
|
||
... | ... | |
if (existing >= 0) {
|
||
return existing;
|
||
}
|
||
long nextUnique = unique.getAndIncrement();
|
||
if (nextUnique > MAX_FINGERPRINT) {
|
||
throw new NamePoolLimitException("Too many distinct names in NamePool");
|
||
}
|
||
int next = (int)nextUnique;
|
||
Integer existing2 = qNameToInteger.putIfAbsent(qName, next);
|
||
if (keyWasAbsent(existing2)) {
|
||
integerToQName.put(next, qName);
|
||
return next;
|
||
} else {
|
||
return existing;
|
||
synchronized (fingerprintGuard) {
|
||
existing = qNameToInteger.getOrDefault(qName, -1);
|
||
if (existing >= 0) {
|
||
return existing;
|
||
}
|
||
long nextUnique = unique.getAndIncrement();
|
||
if (nextUnique > MAX_FINGERPRINT) {
|
||
throw new NamePoolLimitException("Too many distinct names in NamePool");
|
||
}
|
||
int next = (int) nextUnique;
|
||
Integer existing2 = qNameToInteger.putIfAbsent(qName, next);
|
||
if (keyWasAbsent(existing2)) {
|
||
integerToQName.put(next, qName);
|
||
return next;
|
||
} else {
|
||
return existing;
|
||
}
|
||
}
|
||
}
|
||