Skip to content
Permalink
Browse files
[REFACTORING] AbstractHeader was calling toLowerCase twice
This generates needless object allocation and uselessly huggs CPU
  • Loading branch information
chibenwa committed May 25, 2021
1 parent 4551299 commit bbabb72aa029d383190c9e625b302c5e60ddada1
Showing 1 changed file with 3 additions and 2 deletions.
@@ -67,10 +67,11 @@ public AbstractHeader(Header other) {
* @param field the field to add.
*/
public void addField(Field field) {
List<Field> values = fieldMap.get(field.getName().toLowerCase(Locale.US));
String lowerCaseFieldName = field.getName().toLowerCase(Locale.US);
List<Field> values = fieldMap.get(lowerCaseFieldName);
if (values == null) {
values = new LinkedList<Field>();
fieldMap.put(field.getName().toLowerCase(Locale.US), values);
fieldMap.put(lowerCaseFieldName, values);
}
values.add(field);
fields.add(field);

0 comments on commit bbabb72

Please sign in to comment.