MIME4J-302 Parser should avoid multiple calls to "toLowerCase"
authorBenoit Tellier <btellier@linagora.com>
Thu, 17 Jun 2021 08:13:20 +0000 (15:13 +0700)
committerTellier Benoit <btellier@linagora.com>
Fri, 18 Jun 2021 11:44:44 +0000 (18:44 +0700)
commita7a860d3eab7539c53a7d0ed0ea8ddd9e894e532
tree5676c68514a2cf2a569b03a9768e15bdcef399f3
parent46f88dbe77274c6cd371297f97d738aa51778cf9
MIME4J-302 Parser should avoid multiple calls to "toLowerCase"

I was surprised MIME4J parsing spends 18% of its time calling toLowerCase on header names. This represents 12% of allocated memory.

By holding the lowerCased name as part of the field name, and doing lazy initialization on it we can get this down to 6%.
core/src/main/java/org/apache/james/mime4j/stream/FallbackBodyDescriptorBuilder.java
core/src/main/java/org/apache/james/mime4j/stream/Field.java
core/src/main/java/org/apache/james/mime4j/stream/RawField.java
dom/src/main/java/org/apache/james/mime4j/field/AbstractField.java
dom/src/main/java/org/apache/james/mime4j/field/DelegatingFieldParser.java
dom/src/main/java/org/apache/james/mime4j/internal/AbstractEntityBuilder.java
dom/src/main/java/org/apache/james/mime4j/message/AbstractHeader.java
dom/src/main/java/org/apache/james/mime4j/message/DefaultBodyDescriptorBuilder.java