Use LinkedHashSet for HttpHeaders.names() and add Javadoc about the performance of names() and entries()
This commit is contained in:
parent
0d437baef0
commit
ddacf784c1
@ -21,13 +21,13 @@ import java.util.Arrays;
|
|||||||
import java.util.Calendar;
|
import java.util.Calendar;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
|
import java.util.LinkedHashSet;
|
||||||
import java.util.LinkedList;
|
import java.util.LinkedList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Map.Entry;
|
import java.util.Map.Entry;
|
||||||
import java.util.NoSuchElementException;
|
import java.util.NoSuchElementException;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.TreeSet;
|
|
||||||
|
|
||||||
public class DefaultHttpHeaders extends HttpHeaders {
|
public class DefaultHttpHeaders extends HttpHeaders {
|
||||||
|
|
||||||
@ -327,9 +327,7 @@ public class DefaultHttpHeaders extends HttpHeaders {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Set<String> names() {
|
public Set<String> names() {
|
||||||
|
Set<String> names = new LinkedHashSet<String>();
|
||||||
Set<String> names = new TreeSet<String>(String.CASE_INSENSITIVE_ORDER);
|
|
||||||
|
|
||||||
HeaderEntry e = head.after;
|
HeaderEntry e = head.after;
|
||||||
while (e != head) {
|
while (e != head) {
|
||||||
names.add(e.getKey());
|
names.add(e.getKey());
|
||||||
|
@ -27,8 +27,7 @@ import java.util.Map;
|
|||||||
import java.util.Map.Entry;
|
import java.util.Map.Entry;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import static io.netty.handler.codec.http.HttpConstants.CR;
|
import static io.netty.handler.codec.http.HttpConstants.*;
|
||||||
import static io.netty.handler.codec.http.HttpConstants.LF;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -1289,10 +1288,9 @@ public abstract class HttpHeaders implements Iterable<Map.Entry<String, String>>
|
|||||||
public abstract List<String> getAll(CharSequence name);
|
public abstract List<String> getAll(CharSequence name);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the all headers that this message contains.
|
* 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
|
||||||
* @return A {@link List} of the header name-value entries, which will be
|
* entries only, use {@link #iterator()} instead, which has much less overhead.
|
||||||
* empty if no pairs are found
|
|
||||||
*/
|
*/
|
||||||
public abstract List<Map.Entry<String, String>> entries();
|
public abstract List<Map.Entry<String, String>> entries();
|
||||||
|
|
||||||
@ -1310,9 +1308,9 @@ public abstract class HttpHeaders implements Iterable<Map.Entry<String, String>>
|
|||||||
public abstract boolean isEmpty();
|
public abstract boolean isEmpty();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets a {@link Set} of all header names that this message contains
|
* 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
|
||||||
* @return A {@link Set} of all header names
|
* entries only, use {@link #iterator()} instead, which has much less overhead.
|
||||||
*/
|
*/
|
||||||
public abstract Set<String> names();
|
public abstract Set<String> names();
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user