minor gc optimization: better DefaultSpdyHeaders.iterator()

This commit is contained in:
Bill Gallagher 2013-10-11 11:59:30 -04:00 committed by Trustin Lee
parent 39ae2dd3f1
commit e6eb7fa466
2 changed files with 3 additions and 28 deletions

View File

@ -240,16 +240,8 @@ public class DefaultSpdyHeaders extends SpdyHeaders {
}
@Override
public List<Map.Entry<String, String>> entries() {
List<Map.Entry<String, String>> all =
new LinkedList<Map.Entry<String, String>>();
HeaderEntry e = head.after;
while (e != head) {
all.add(e);
e = e.after;
}
return all;
public Iterator<Map.Entry<String, String>> iterator() {
return new HeaderIterator();
}
@Override

View File

@ -38,11 +38,6 @@ public abstract class SpdyHeaders implements Iterable<Map.Entry<String, String>>
return Collections.emptyList();
}
@Override
public List<Map.Entry<String, String>> entries() {
return Collections.emptyList();
}
@Override
public boolean contains(String name) {
return false;
@ -90,7 +85,7 @@ public abstract class SpdyHeaders implements Iterable<Map.Entry<String, String>>
@Override
public Iterator<Map.Entry<String, String>> iterator() {
return entries().iterator();
return Collections.<Map.Entry<String, String>>emptyList().iterator();
}
@Override
@ -420,10 +415,6 @@ public abstract class SpdyHeaders implements Iterable<Map.Entry<String, String>>
frame.headers().set(HttpNames.VERSION, httpVersion.text());
}
}
@Override
public Iterator<Map.Entry<String, String>> iterator() {
return entries().iterator();
}
/**
* Returns the header value with the specified header name. If there is
@ -442,14 +433,6 @@ public abstract class SpdyHeaders implements Iterable<Map.Entry<String, String>>
*/
public abstract List<String> getAll(String name);
/**
* Returns all header names and values that this frame contains.
*
* @return the {@link List} of the header name-value pairs. An empty list
* if there is no header in this message.
*/
public abstract List<Map.Entry<String, String>> entries();
/**
* Returns {@code true} if and only if there is a header with the specified
* header name.