minor optimization

This commit is contained in:
zzz
2016-12-16 17:50:26 +00:00
parent 0c76201bd9
commit 328f544de1

View File

@@ -816,8 +816,8 @@ public class I2PTunnelHTTPServer extends I2PTunnelServer {
*/
private static void addEntry(Map<String, List<String>> headers, String key, String value) {
List<String> entry = headers.get(key);
if(entry == null) {
headers.put(key, entry = new ArrayList<String>());
if (entry == null) {
headers.put(key, entry = new ArrayList<String>(1));
}
entry.add(value);
}
@@ -827,10 +827,11 @@ public class I2PTunnelHTTPServer extends I2PTunnelServer {
*/
private static void setEntry(Map<String, List<String>> headers, String key, String value) {
List<String> entry = headers.get(key);
if(entry == null) {
headers.put(key, entry = new ArrayList<String>());
}
if (entry == null) {
headers.put(key, entry = new ArrayList<String>(1));
} else {
entry.clear();
}
entry.add(value);
}