mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
avoid array list creation
This commit is contained in:
+17
-9
@@ -144,16 +144,24 @@ public class StorageData {
|
||||
void setState(@NotNull final String componentName, final Element element) {
|
||||
element.setName(COMPONENT);
|
||||
|
||||
//componentName should be first!
|
||||
final List<Attribute> attributes = new ArrayList<Attribute>(element.getAttributes());
|
||||
for (Attribute attribute : attributes) {
|
||||
element.removeAttribute(attribute);
|
||||
// componentName should be first
|
||||
List<Attribute> elementAttributes = element.getAttributes();
|
||||
if (elementAttributes.isEmpty()) {
|
||||
element.setAttribute(NAME, componentName);
|
||||
}
|
||||
|
||||
element.setAttribute(NAME, componentName);
|
||||
|
||||
for (Attribute attribute : attributes) {
|
||||
element.setAttribute(attribute.getName(), attribute.getValue());
|
||||
else {
|
||||
Attribute nameAttribute = element.getAttribute(NAME);
|
||||
if (nameAttribute == null) {
|
||||
nameAttribute = new Attribute(NAME, componentName);
|
||||
elementAttributes.add(0, nameAttribute);
|
||||
}
|
||||
else {
|
||||
nameAttribute.setValue(componentName);
|
||||
if (elementAttributes.get(0) != nameAttribute) {
|
||||
elementAttributes.remove(nameAttribute);
|
||||
elementAttributes.add(0, nameAttribute);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
myComponentStates.put(componentName, element);
|
||||
|
||||
Reference in New Issue
Block a user