Skip to content

Commit

Permalink
Use nested maps instead of guava table
Browse files Browse the repository at this point in the history
  • Loading branch information
Equinox- authored and angelozerr committed Oct 24, 2024
1 parent d1e719c commit f1c9376
Showing 1 changed file with 8 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@
import java.util.logging.Level;
import java.util.logging.Logger;

import com.google.common.collect.HashBasedTable;
import com.google.common.collect.Table;
import org.apache.xerces.impl.dv.XSSimpleType;
import org.apache.xerces.impl.dv.xs.XSSimpleTypeDecl;
import org.apache.xerces.impl.xs.SchemaGrammar;
Expand Down Expand Up @@ -84,7 +82,7 @@ public class CMXSDDocument implements CMDocument, XSElementDeclHelper {
private final XSModel model;

private final Map<XSElementDeclaration, CMXSDElementDeclaration> elementMappings;
private final Table<CMXSDElementDeclaration, XSTypeDefinition, CMXSDElementDeclaration> refinedElementMappings;
private final Map<CMXSDElementDeclaration, Map<XSTypeDefinition, CMXSDElementDeclaration>> refinedElementMappings;

private Collection<CMElementDeclaration> elements;

Expand All @@ -96,7 +94,7 @@ public CMXSDDocument(XSModel model, XSLoaderImpl xsLoaderImpl) {
this.model = model;
this.xsLoader = xsLoaderImpl;
this.elementMappings = new HashMap<>();
this.refinedElementMappings = HashBasedTable.create();
this.refinedElementMappings = new HashMap<>();
this.tracker = createFilesChangedTracker(model);
}

Expand Down Expand Up @@ -196,10 +194,14 @@ public CMElementDeclaration findCMElement(DOMElement element, String namespace)
XSTypeDefinition exactType = findXsiType(elt);
if (exactType != null) {
CMXSDElementDeclaration baseDeclaration = declaration;
declaration = refinedElementMappings.get(baseDeclaration, exactType);
Map<XSTypeDefinition, CMXSDElementDeclaration> refinedElementMappingsForDeclaration =
refinedElementMappings.computeIfAbsent(baseDeclaration,
_key -> new HashMap<>());

declaration = refinedElementMappingsForDeclaration.get(exactType);
if (declaration == null) {
declaration = baseDeclaration.refineType(exactType);
refinedElementMappings.put(baseDeclaration, exactType, declaration);
refinedElementMappingsForDeclaration.put(exactType, declaration);
}
}
}
Expand Down

0 comments on commit f1c9376

Please sign in to comment.