Skip to content

Commit

Permalink
Replace LinkedList with ArrayList (#13016)
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
needmorecode and normanmaurer committed Nov 24, 2022
1 parent d24defc commit 3bff0be
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
Expand Up @@ -15,7 +15,7 @@
*/
package io.netty.handler.codec.xml;

import java.util.LinkedList;
import java.util.ArrayList;
import java.util.List;

/**
Expand All @@ -28,7 +28,7 @@ public abstract class XmlElement {
private final String namespace;
private final String prefix;

private final List<XmlNamespace> namespaces = new LinkedList<XmlNamespace>();
private final List<XmlNamespace> namespaces = new ArrayList<XmlNamespace>();

protected XmlElement(String name, String namespace, String prefix) {
this.name = name;
Expand Down
Expand Up @@ -15,15 +15,15 @@
*/
package io.netty.handler.codec.xml;

import java.util.LinkedList;
import java.util.ArrayList;
import java.util.List;

/**
* Specific {@link XmlElement} representing beginning of element.
*/
public class XmlElementStart extends XmlElement {

private final List<XmlAttribute> attributes = new LinkedList<XmlAttribute>();
private final List<XmlAttribute> attributes = new ArrayList<XmlAttribute>();

public XmlElementStart(String name, String namespace, String prefix) {
super(name, namespace, prefix);
Expand Down

0 comments on commit 3bff0be

Please sign in to comment.