Skip to content

Commit

Permalink
Use LinkedHashSet for HttpHeaders.names() and add Javadoc about the p…
Browse files Browse the repository at this point in the history
…erformance of names() and entries()
  • Loading branch information
trustin committed Dec 22, 2013
1 parent 0d437ba commit ddacf78
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,13 @@
import java.util.Calendar;
import java.util.Date;
import java.util.Iterator;
import java.util.LinkedHashSet;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.NoSuchElementException;
import java.util.Set;
import java.util.TreeSet;

public class DefaultHttpHeaders extends HttpHeaders {

Expand Down Expand Up @@ -327,9 +327,7 @@ public boolean contains(CharSequence name, CharSequence value, boolean ignoreCas

@Override
public Set<String> names() {

Set<String> names = new TreeSet<String>(String.CASE_INSENSITIVE_ORDER);

Set<String> names = new LinkedHashSet<String>();
HeaderEntry e = head.after;
while (e != head) {
names.add(e.getKey());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,7 @@
import java.util.Map.Entry;
import java.util.Set;

import static io.netty.handler.codec.http.HttpConstants.CR;
import static io.netty.handler.codec.http.HttpConstants.LF;
import static io.netty.handler.codec.http.HttpConstants.*;


/**
Expand Down Expand Up @@ -1289,10 +1288,9 @@ protected HttpHeaders() { }
public abstract List<String> getAll(CharSequence name);

/**
* Returns the all headers that this message contains.
*
* @return A {@link List} of the header name-value entries, which will be
* empty if no pairs are found
* Returns a new {@link List} that contains all headers in this object. Note that modifying the
* returned {@link List} will not affect the state of this object. If you intend to enumerate over the header
* entries only, use {@link #iterator()} instead, which has much less overhead.
*/
public abstract List<Map.Entry<String, String>> entries();

Expand All @@ -1310,9 +1308,9 @@ protected HttpHeaders() { }
public abstract boolean isEmpty();

/**
* Gets a {@link Set} of all header names that this message contains
*
* @return A {@link Set} of all header names
* Returns a new {@link Set} that contains the names of all headers in this object. Note that modifying the
* returned {@link Set} will not affect the state of this object. If you intend to enumerate over the header
* entries only, use {@link #iterator()} instead, which has much less overhead.
*/
public abstract Set<String> names();

Expand Down

0 comments on commit ddacf78

Please sign in to comment.