Headers remove infrequently used member variables
Motivation: There are two member variables (addAllVisitor, setAllVisitor) which are likely not to be used in the majority of use cases. Modifications: Remove these member variables and rely on a method to return a new object when needed. Result: Two less member variables for each DefaultHeaders instance.
This commit is contained in:
parent
3b1f15e366
commit
cee60304de
@ -90,8 +90,6 @@ public class DefaultHeaders<T> implements Headers<T> {
|
|||||||
private final ValueConverter<T> valueConverter;
|
private final ValueConverter<T> valueConverter;
|
||||||
private final NameConverter<T> nameConverter;
|
private final NameConverter<T> nameConverter;
|
||||||
private final int bucketSize;
|
private final int bucketSize;
|
||||||
private EntryVisitor<T> setAllVisitor;
|
|
||||||
private EntryVisitor<T> addAllVisitor;
|
|
||||||
int size;
|
int size;
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
@ -1307,36 +1305,24 @@ public class DefaultHeaders<T> implements Headers<T> {
|
|||||||
return removed;
|
return removed;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Lazy initialization of the visitor which will set all headers.
|
|
||||||
*/
|
|
||||||
private EntryVisitor<T> setAllVisitor() {
|
private EntryVisitor<T> setAllVisitor() {
|
||||||
if (setAllVisitor == null) {
|
return new EntryVisitor<T>() {
|
||||||
setAllVisitor = new EntryVisitor<T>() {
|
@Override
|
||||||
@Override
|
public boolean visit(Entry<T, T> entry) {
|
||||||
public boolean visit(Entry<T, T> entry) {
|
set(entry.getKey(), entry.getValue());
|
||||||
set(entry.getKey(), entry.getValue());
|
return true;
|
||||||
return true;
|
}
|
||||||
}
|
};
|
||||||
};
|
|
||||||
}
|
|
||||||
return setAllVisitor;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Lazy initialization of the visitor which will add all headers.
|
|
||||||
*/
|
|
||||||
private EntryVisitor<T> addAllVisitor() {
|
private EntryVisitor<T> addAllVisitor() {
|
||||||
if (addAllVisitor == null) {
|
return new EntryVisitor<T>() {
|
||||||
addAllVisitor = new EntryVisitor<T>() {
|
@Override
|
||||||
@Override
|
public boolean visit(Entry<T, T> entry) {
|
||||||
public boolean visit(Entry<T, T> entry) {
|
add(entry.getKey(), entry.getValue());
|
||||||
add(entry.getKey(), entry.getValue());
|
return true;
|
||||||
return true;
|
}
|
||||||
}
|
};
|
||||||
};
|
|
||||||
}
|
|
||||||
return addAllVisitor;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private final class HeaderEntry implements Map.Entry<T, T> {
|
private final class HeaderEntry implements Map.Entry<T, T> {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user