Mozilla bug 1506133 - Remove Portability.newLocalFromLocal, and interner argument from cloneAttributes. r=hsivonen.
authorEmilio Cobos Álvarez <emilio@crisal.io>
Fri, 09 Nov 2018 15:38:47 +0100
changeset 878 bc3e1a11a43a6d7f8e266011625be5d124a176da
parent 877 2762c45ba362689bc90cc3ffeb0e8a37e568e716
child 879 bbeeee84648bdd84ba9ff280f55d60b0bf7b1e96
push id193
push userhsivonen@mozilla.com
push dateThu, 13 Dec 2018 11:42:39 +0000
reviewershsivonen
bugs1506133
Mozilla bug 1506133 - Remove Portability.newLocalFromLocal, and interner argument from cloneAttributes. r=hsivonen.
src/nu/validator/htmlparser/impl/HtmlAttributes.java
src/nu/validator/htmlparser/impl/Portability.java
src/nu/validator/htmlparser/impl/Tokenizer.java
src/nu/validator/htmlparser/impl/TreeBuilder.java
--- a/src/nu/validator/htmlparser/impl/HtmlAttributes.java
+++ b/src/nu/validator/htmlparser/impl/HtmlAttributes.java
@@ -430,18 +430,17 @@ public final class HtmlAttributes implem
     public void adjustForMath() {
         mode = AttributeName.MATHML;
     }
 
     public void adjustForSvg() {
         mode = AttributeName.SVG;
     }
 
-    public HtmlAttributes cloneAttributes(Interner interner)
-            throws SAXException {
+    public HtmlAttributes cloneAttributes() throws SAXException {
         assert (length == 0
                 && xmlnsLength == 0
                 )
                 || mode == 0 || mode == 3;
         HtmlAttributes clone = new HtmlAttributes(0);
         for (int i = 0; i < length; i++) {
             clone.addAttribute(names[i],
                     values[i]
--- a/src/nu/validator/htmlparser/impl/Portability.java
+++ b/src/nu/validator/htmlparser/impl/Portability.java
@@ -61,20 +61,16 @@ public final class Portability {
     public static char[] newCharArrayFromLocal(@Local String local) {
         return local.toCharArray();
     }
 
     public static char[] newCharArrayFromString(String string) {
         return string.toCharArray();
     }
 
-    public static @Local String newLocalFromLocal(@Local String local, Interner interner) {
-        return local;
-    }
-
     // Deallocation methods
 
     public static void releaseString(String str) {
         // No-op in Java
     }
 
     // Comparison methods
 
--- a/src/nu/validator/htmlparser/impl/Tokenizer.java
+++ b/src/nu/validator/htmlparser/impl/Tokenizer.java
@@ -6854,23 +6854,17 @@ public class Tokenizer implements Locato
         lo = other.lo;
         hi = other.hi;
         candidate = other.candidate;
         charRefBufMark = other.charRefBufMark;
         value = other.value;
         seenDigits = other.seenDigits;
         endTag = other.endTag;
         shouldSuspend = false;
-
-        if (other.doctypeName == null) {
-            doctypeName = null;
-        } else {
-            doctypeName = Portability.newLocalFromLocal(other.doctypeName,
-                    interner);
-        }
+        doctypeName = other.doctypeName;
 
         Portability.releaseString(systemIdentifier);
         if (other.systemIdentifier == null) {
             systemIdentifier = null;
         } else {
             systemIdentifier = Portability.newStringFromString(other.systemIdentifier);
         }
 
@@ -6885,42 +6879,42 @@ public class Tokenizer implements Locato
         if (other.tagName == null) {
             tagName = null;
         } else if (other.tagName.isInterned()) {
             tagName = other.tagName;
         } else {
             // In the C++ case, the atoms in the other tokenizer are from a
             // different tokenizer-scoped atom table. Therefore, we have to
             // obtain the correspoding atom from our own atom table.
-            nonInternedTagName.setNameForNonInterned(Portability.newLocalFromLocal(other.tagName.getName(), interner)
+            nonInternedTagName.setNameForNonInterned(other.tagName.getName()
                     // CPPONLY: , other.tagName.isCustom()
                     );
             tagName = nonInternedTagName;
         }
 
         // [NOCPP[
         attributeName = other.attributeName;
         // ]NOCPP]
         // CPPONLY: if (other.attributeName == null) {
         // CPPONLY:     attributeName = null;
         // CPPONLY: } else if (other.attributeName.isInterned()) {
         // CPPONLY:     attributeName = other.attributeName;
         // CPPONLY: } else {
         // CPPONLY:     // In the C++ case, the atoms in the other tokenizer are from a
         // CPPONLY:     // different tokenizer-scoped atom table. Therefore, we have to
         // CPPONLY:     // obtain the correspoding atom from our own atom table.
-        // CPPONLY:     nonInternedAttributeName.setNameForNonInterned(Portability.newLocalFromLocal(other.attributeName.getLocal(AttributeName.HTML), interner));
+        // CPPONLY:     nonInternedAttributeName.setNameForNonInterned(other.attributeName.getLocal(AttributeName.HTML));
         // CPPONLY:     attributeName = nonInternedAttributeName;
         // CPPONLY: }
 
         Portability.delete(attributes);
         if (other.attributes == null) {
             attributes = null;
         } else {
-            attributes = other.attributes.cloneAttributes(interner);
+            attributes = other.attributes.cloneAttributes();
         }
     }
 
     public void initializeWithoutStarting() throws SAXException {
         confident = false;
         strBuf = null;
         line = 1;
         // CPPONLY: attributeLine = 1;
@@ -7146,18 +7140,19 @@ public class Tokenizer implements Locato
      */
     public void setEncodingDeclarationHandler(
             EncodingDeclarationHandler encodingDeclarationHandler) {
         this.encodingDeclarationHandler = encodingDeclarationHandler;
     }
 
     void destructor() {
         Portability.delete(nonInternedTagName);
+        nonInternedTagName = null;
         // CPPONLY: Portability.delete(nonInternedAttributeName);
-        nonInternedTagName = null;
+        // CPPONLY: nonInternedAttributeName = null;
         // The translator will write refcount tracing stuff here
         Portability.delete(attributes);
         attributes = null;
     }
 
     // [NOCPP[
 
     /**
--- a/src/nu/validator/htmlparser/impl/TreeBuilder.java
+++ b/src/nu/validator/htmlparser/impl/TreeBuilder.java
@@ -4781,17 +4781,17 @@ public abstract class TreeBuilder<T> imp
                 // now node is both on stack and in the list
                 if (nodePos == furthestBlockPos) {
                     bookmark = nodeListPos + 1;
                 }
                 // if (hasChildren(node.node)) { XXX AAA CHANGE
                 assert node == listOfActiveFormattingElements[nodeListPos];
                 assert node == stack[nodePos];
                 T clone = createElement("http://www.w3.org/1999/xhtml",
-                        node.name, node.attributes.cloneAttributes(null), commonAncestor.node
+                        node.name, node.attributes.cloneAttributes(), commonAncestor.node
                         // CPPONLY: , htmlCreator(node.getHtmlCreator())
                         );
                 StackNode<T> newNode = createStackNode(node.getFlags(), node.ns,
                         node.name, clone, node.popName, node.attributes
                         // CPPONLY: , node.getHtmlCreator()
                         // [NOCPP[
                         , node.getLocator()
                         // ]NOCPP]
@@ -4813,17 +4813,17 @@ public abstract class TreeBuilder<T> imp
                 detachFromParent(lastNode.node);
                 insertIntoFosterParent(lastNode.node);
             } else {
                 detachFromParent(lastNode.node);
                 appendElement(lastNode.node, commonAncestor.node);
             }
             T clone = createElement("http://www.w3.org/1999/xhtml",
                     formattingElt.name,
-                    formattingElt.attributes.cloneAttributes(null), furthestBlock.node
+                    formattingElt.attributes.cloneAttributes(), furthestBlock.node
                     // CPPONLY: , htmlCreator(formattingElt.getHtmlCreator())
                     );
             StackNode<T> formattingClone = createStackNode(
                     formattingElt.getFlags(), formattingElt.ns,
                     formattingElt.name, clone, formattingElt.popName,
                     formattingElt.attributes
                     // CPPONLY: , formattingElt.getHtmlCreator()
                     // [NOCPP[
@@ -5000,22 +5000,22 @@ public abstract class TreeBuilder<T> imp
         while (entryPos < listPtr) {
             entryPos++;
             StackNode<T> entry = listOfActiveFormattingElements[entryPos];
             StackNode<T> currentNode = stack[currentPtr];
 
             T clone;
             if (currentNode.isFosterParenting()) {
                 clone = createAndInsertFosterParentedElement("http://www.w3.org/1999/xhtml", entry.name,
-                        entry.attributes.cloneAttributes(null)
+                        entry.attributes.cloneAttributes()
                         // CPPONLY: , htmlCreator(entry.getHtmlCreator())
                         );
             } else {
                 clone = createElement("http://www.w3.org/1999/xhtml", entry.name,
-                        entry.attributes.cloneAttributes(null), currentNode.node
+                        entry.attributes.cloneAttributes(), currentNode.node
                         // CPPONLY: , htmlCreator(entry.getHtmlCreator())
                         );
                 appendElement(clone, currentNode.node);
             }
 
             StackNode<T> entryClone = createStackNode(entry.getFlags(),
                     entry.ns, entry.name, clone, entry.popName,
                     entry.attributes
@@ -5419,17 +5419,17 @@ public abstract class TreeBuilder<T> imp
 
     private void appendToCurrentNodeAndPushFormattingElementMayFoster(
             ElementName elementName, HtmlAttributes attributes)
             throws SAXException {
         // [NOCPP[
         checkAttributes(attributes, "http://www.w3.org/1999/xhtml");
         // ]NOCPP]
         // This method can't be called for custom elements
-        HtmlAttributes clone = attributes.cloneAttributes(null);
+        HtmlAttributes clone = attributes.cloneAttributes();
         // Attributes must not be read after calling createElement, because
         // createElement may delete attributes in C++.
         T elt;
         StackNode<T> current = stack[currentPtr];
         if (current.isFosterParenting()) {
             fatal();
             elt = createAndInsertFosterParentedElement("http://www.w3.org/1999/xhtml", elementName.getName(), attributes
                     // CPPONLY: , htmlCreator(elementName.getHtmlCreator())
@@ -6125,17 +6125,17 @@ public abstract class TreeBuilder<T> imp
             throws SAXException {
         StackNode<T>[] listCopy = new StackNode[listPtr + 1];
         for (int i = 0; i < listCopy.length; i++) {
             StackNode<T> node = listOfActiveFormattingElements[i];
             if (node != null) {
                 StackNode<T> newNode = new StackNode<T>(-1);
                 newNode.setValues(node.getFlags(), node.ns,
                         node.name, node.node, node.popName,
-                        node.attributes.cloneAttributes(null)
+                        node.attributes.cloneAttributes()
                         // CPPONLY: , node.getHtmlCreator()
                         // [NOCPP[
                         , node.getLocator()
                         // ]NOCPP]
                 );
                 listCopy[i] = newNode;
             } else {
                 listCopy[i] = null;
@@ -6212,17 +6212,17 @@ public abstract class TreeBuilder<T> imp
             if (templateModeStackCopy[i] != templateModeStack[i]) {
                 return false;
             }
         }
         return true;
     }
 
     @SuppressWarnings("unchecked") public void loadState(
-            TreeBuilderState<T> snapshot, Interner interner)
+            TreeBuilderState<T> snapshot)
             throws SAXException {
         // CPPONLY: mCurrentHtmlScriptIsAsyncOrDefer = false;
         StackNode<T>[] stackCopy = snapshot.getStack();
         int stackLen = snapshot.getStackLength();
         StackNode<T>[] listCopy = snapshot.getListOfActiveFormattingElements();
         int listLen = snapshot.getListOfActiveFormattingElementsLength();
         int[] templateModeStackCopy = snapshot.getTemplateModeStack();
         int templateModeStackLen = snapshot.getTemplateModeStackLength();
@@ -6249,36 +6249,36 @@ public abstract class TreeBuilder<T> imp
             templateModeStack = new int[templateModeStackLen];
         }
         templateModePtr = templateModeStackLen - 1;
 
         for (int i = 0; i < listLen; i++) {
             StackNode<T> node = listCopy[i];
             if (node != null) {
                 StackNode<T> newNode = createStackNode(node.getFlags(), node.ns,
-                        Portability.newLocalFromLocal(node.name, interner), node.node,
-                        Portability.newLocalFromLocal(node.popName, interner),
-                        node.attributes.cloneAttributes(null)
+                        node.name, node.node,
+                        node.popName,
+                        node.attributes.cloneAttributes()
                         // CPPONLY: , node.getHtmlCreator()
                         // [NOCPP[
                         , node.getLocator()
                 // ]NOCPP]
                 );
                 listOfActiveFormattingElements[i] = newNode;
             } else {
                 listOfActiveFormattingElements[i] = null;
             }
         }
         for (int i = 0; i < stackLen; i++) {
             StackNode<T> node = stackCopy[i];
             int listIndex = findInArray(node, listCopy);
             if (listIndex == -1) {
                 StackNode<T> newNode = createStackNode(node.getFlags(), node.ns,
-                        Portability.newLocalFromLocal(node.name, interner), node.node,
-                        Portability.newLocalFromLocal(node.popName, interner),
+                        node.name, node.node,
+                        node.popName,
                         null
                         // CPPONLY: , node.getHtmlCreator()
                         // [NOCPP[
                         , node.getLocator()
                 // ]NOCPP]
                 );
                 stack[i] = newNode;
             } else {