fix: remove unneeded depth/logic in serializer
@@ -411,14 +411,6 @@ public class MXSerializer implements XmlSerializer {
throw new IllegalArgumentException("prefix must be not null" + getLocation());
}
- // check that prefix is not duplicated ...
- for (int i = elNamespaceCount[depth]; i < namespaceEnd; i++) {
- if (prefix == namespacePrefix[i]) {
- // Toss out extra namespaces at same depth to fix #1456
- return;
- }
- }
-
if (!namesInterned) {
namespace = namespace.intern();
} else if (checkNamesInterned) {
@@ -461,16 +453,12 @@ public class MXSerializer implements XmlSerializer {
// first check if namespace is already in scope
for (int i = namespaceEnd - 1; i >= 0; --i) {
- if (namespace == namespaceUri[i]) {
+ if (namespace.equals(namespaceUri[i])) {
final String prefix = namespacePrefix[i];
- if (nonEmpty && prefix.length() == 0)
+ if (nonEmpty && prefix.length() == 0) {
continue;
- // now check that prefix is still in scope
- for (int p = namespaceEnd - 1; p > i; --p) {
- if (prefix == namespacePrefix[p]) {
- // too bad - prefix is redeclared with different namespace
- }
}
+
return prefix;
}
}
@@ -483,21 +471,13 @@ public class MXSerializer implements XmlSerializer {
}
private String generatePrefix(String namespace) {
- while (true) {
++autoDeclaredPrefixes;
// fast lookup uses table that was pre-initialized in static{} ....
final String prefix = autoDeclaredPrefixes < precomputedPrefixes.length
? precomputedPrefixes[autoDeclaredPrefixes]
: ("n" + autoDeclaredPrefixes).intern();
- // make sure this prefix is not declared in any scope (avoid hiding in-scope prefixes)!
- for (int i = namespaceEnd - 1; i >= 0; --i) {
- if (prefix == namespacePrefix[i]) {
- // prefix is already declared - generate new and try again
- }
- }
// declare prefix
-
if (namespaceEnd >= namespacePrefix.length) {
ensureNamespacesCapacity();
}
@@ -507,7 +487,6 @@ public class MXSerializer implements XmlSerializer {
return prefix;
}
- }
@Override
public int getDepth() {
