changeset 41429:b556ea084899

8167002: JAXP schema validator: Use HashSet instead of ArrayList for tracking XML IDs Reviewed-by: joehw, dfuchs, redestad, lancea Contributed-by: jktomer@google.com
author martin
date Mon, 03 Oct 2016 17:35:11 -0700
parents 65477538bec3
children cfaac7b7fee5
files jaxp/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/impl/validation/ValidationState.java
diffstat 1 files changed, 7 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/jaxp/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/impl/validation/ValidationState.java	Wed Jul 05 22:17:45 2017 +0200
+++ b/jaxp/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/impl/validation/ValidationState.java	Mon Oct 03 17:35:11 2016 -0700
@@ -52,7 +52,7 @@
     private SymbolTable fSymbolTable            = null;
     private Locale fLocale                      = null;
 
-    private ArrayList<String> fIdList;
+    private HashSet<String> fIds;
     private ArrayList<String> fIdRefList;
 
     //
@@ -97,7 +97,7 @@
             String key;
             for (int i = 0; i < fIdRefList.size(); i++) {
                 key = fIdRefList.get(i);
-                if (fIdList == null || !fIdList.contains(key)) {
+                if (fIds == null || !fIds.contains(key)) {
                     if (missingIDs == null) {
                         missingIDs = new HashSet();
                     }
@@ -112,7 +112,7 @@
         fExtraChecking = true;
         fFacetChecking = true;
         fNamespaces = true;
-        fIdList = null;
+        fIds = null;
         fIdRefList = null;
         fEntityState = null;
         fNamespaceContext = null;
@@ -126,7 +126,7 @@
      * the two tables.
      */
     public void resetIDTables() {
-        fIdList = null;
+        fIds = null;
         fIdRefList = null;
     }
 
@@ -168,12 +168,11 @@
 
     // id
     public boolean isIdDeclared(String name) {
-        if (fIdList == null) return false;
-        return fIdList.contains(name);
+        return fIds != null && fIds.contains(name);
     }
     public void addId(String name) {
-        if (fIdList == null) fIdList = new ArrayList();
-        fIdList.add(name);
+        if (fIds == null) fIds = new HashSet<>();
+        fIds.add(name);
     }
 
     // idref