[265775] The XML editor uses a lot of memory
diff --git a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/document/AttrImpl.java b/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/document/AttrImpl.java index fcb80b6..5ff5816 100644 --- a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/document/AttrImpl.java +++ b/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/document/AttrImpl.java
@@ -575,12 +575,15 @@ return (this.fName == null); if (this.fName == null) return false; - if (this.fName.length != name.length()) + return CharOperation.equals(this.fName, name.toCharArray(), ignoreCase()); + } + + protected boolean matchName(char[] name) { + if (name == null) + return (this.fName == null); + if (this.fName == null) return false; - String stringName = new String(this.fName); - if (stringName.equals(name)) - return true; - return stringName.equalsIgnoreCase(name) && ignoreCase(); + return CharOperation.equals(this.fName, name, ignoreCase()); }
diff --git a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/document/CharOperation.java b/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/document/CharOperation.java index 783e344..a446bde 100644 --- a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/document/CharOperation.java +++ b/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/document/CharOperation.java
@@ -27,4 +27,65 @@ return -1; } + + /** + * note: This method taken from org.eclipse.jdt.core.compiler.CharOperation + * + * Answers true if the two arrays are identical character by character, otherwise false. + * The equality is case sensitive. + * <br> + * <br> + * For example: + * <ol> + * <li><pre> + * first = null + * second = null + * result => true + * </pre> + * </li> + * <li><pre> + * first = { } + * second = null + * result => false + * </pre> + * </li> + * <li><pre> + * first = { 'a' } + * second = { 'a' } + * result => true + * </pre> + * </li> + * <li><pre> + * first = { 'a' } + * second = { 'A' } + * result => false + * </pre> + * </li> + * </ol> + * @param first the first array + * @param second the second array + * @return true if the two arrays are identical character by character, otherwise false + */ + public static final boolean equals(char[] first, char[] second, boolean ignoreCase) { + if (first == second) + return true; + if (first == null || second == null) + return false; + if (first.length != second.length) + return false; + + for (int i = first.length; --i >= 0;) { + if (ignoreCase) { + if (Character.toUpperCase(first[i]) != Character.toUpperCase(second[i])) { + return false; + } + } + else { + if (first[i] != second[i]) { + return false; + } + } + } + return true; + } }
diff --git a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/document/ElementImpl.java b/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/document/ElementImpl.java index 025c047..2de1968 100644 --- a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/document/ElementImpl.java +++ b/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/document/ElementImpl.java
@@ -254,11 +254,12 @@ return null; // no attribute int length = this.attrNodes.getLength(); + char[] nameChars = name.toCharArray(); for (int i = 0; i < length; i++) { AttrImpl attr = (AttrImpl) this.attrNodes.item(i); if (attr == null) continue; - if (attr.matchName(name)) + if (attr.matchName(nameChars)) return attr; // found }