Skip to content

Commit 3bff0be

Browse files
Replace LinkedList with ArrayList (#13016)
Motivation: ArrayList is more efficient than LinkedList in the space cost. ArrayList is almost as efficient as LinkedList in the time cost of tail insertion, which are the practical use cases of the two lists I modified. Modification: Replace LinkedList with ArrayList. Result: Less space cost. Co-authored-by: Norman Maurer <norman_maurer@apple.com>
1 parent d24defc commit 3bff0be

2 files changed

Lines changed: 4 additions & 4 deletions

File tree

codec-xml/src/main/java/io/netty/handler/codec/xml/XmlElement.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
*/
1616
package io.netty.handler.codec.xml;
1717

18-
import java.util.LinkedList;
18+
import java.util.ArrayList;
1919
import java.util.List;
2020

2121
/**
@@ -28,7 +28,7 @@ public abstract class XmlElement {
2828
private final String namespace;
2929
private final String prefix;
3030

31-
private final List<XmlNamespace> namespaces = new LinkedList<XmlNamespace>();
31+
private final List<XmlNamespace> namespaces = new ArrayList<XmlNamespace>();
3232

3333
protected XmlElement(String name, String namespace, String prefix) {
3434
this.name = name;

codec-xml/src/main/java/io/netty/handler/codec/xml/XmlElementStart.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,15 @@
1515
*/
1616
package io.netty.handler.codec.xml;
1717

18-
import java.util.LinkedList;
18+
import java.util.ArrayList;
1919
import java.util.List;
2020

2121
/**
2222
* Specific {@link XmlElement} representing beginning of element.
2323
*/
2424
public class XmlElementStart extends XmlElement {
2525

26-
private final List<XmlAttribute> attributes = new LinkedList<XmlAttribute>();
26+
private final List<XmlAttribute> attributes = new ArrayList<XmlAttribute>();
2727

2828
public XmlElementStart(String name, String namespace, String prefix) {
2929
super(name, namespace, prefix);

0 commit comments

Comments
 (0)