mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
avoid AttributeList creation if no attributes
This commit is contained in:
@@ -1,16 +1,4 @@
|
||||
// Copyright 2000-2017 JetBrains s.r.o.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
package org.jdom;
|
||||
|
||||
import com.intellij.openapi.util.Comparing;
|
||||
@@ -19,6 +7,7 @@ import com.intellij.util.containers.StringInterner;
|
||||
import gnu.trove.TObjectHashingStrategy;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
public class JDOMInterner {
|
||||
@@ -70,7 +59,7 @@ public class JDOMInterner {
|
||||
});
|
||||
|
||||
private static int computeAttributesHashCode(Element e) {
|
||||
List<Attribute> attributes = e.getAttributes();
|
||||
List<Attribute> attributes = getAttributes(e);
|
||||
if (attributes instanceof ImmutableSameTypeAttributeList) {
|
||||
return attributes.hashCode();
|
||||
}
|
||||
@@ -81,6 +70,12 @@ public class JDOMInterner {
|
||||
return result;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private static List<Attribute> getAttributes(@NotNull Element e) {
|
||||
// avoid AttributeList creation if no attributes
|
||||
return e.hasAttributes() ? e.getAttributes() : Collections.<Attribute>emptyList();
|
||||
}
|
||||
|
||||
private static boolean attributesEqual(Element o1, Element o2) {
|
||||
if (o1 instanceof ImmutableElement) {
|
||||
return ((ImmutableElement)o1).attributesEqual(o2);
|
||||
@@ -88,8 +83,8 @@ public class JDOMInterner {
|
||||
if (o2 instanceof ImmutableElement) {
|
||||
return ((ImmutableElement)o2).attributesEqual(o1);
|
||||
}
|
||||
List<Attribute> a1 = o1.getAttributes();
|
||||
List<Attribute> a2 = o2.getAttributes();
|
||||
List<Attribute> a1 = getAttributes(o1);
|
||||
List<Attribute> a2 = getAttributes(o2);
|
||||
if (a1.size() != a2.size()) return false;
|
||||
for (int i=0; i<a1.size(); i++) {
|
||||
Attribute attr1 = a1.get(i);
|
||||
|
||||
Reference in New Issue
Block a user