Guillaume Nodet created CAMEL-23691:
---------------------------------------

             Summary: camel-core - Improve CaseInsensitiveMap with O(1) hash 
table and header key deduplication
                 Key: CAMEL-23691
                 URL: https://issues.apache.org/jira/browse/CAMEL-23691
             Project: Camel
          Issue Type: Improvement
            Reporter: Guillaume Nodet
             Fix For: 4.21.0


Replace the TreeMap-based CaseInsensitiveMap with a custom hash table 
implementation, improving the performance of every header access in every Camel 
route.

CaseInsensitiveMap is the default headers map for every Exchange in Camel. The 
TreeMap provides O(log n) lookups with string comparisons at every tree node. 
The new implementation provides:

- O(1) for get, put, containsKey, remove
- Zero allocation on lookups — case-insensitive hash computed char-by-char
- Header key deduplication — well-known Exchange header constants are 
registered at startup via ExchangeConstantProvider, reducing memory across 
exchanges
- Entries stored in insertion order (deterministic iteration)
- No external dependencies, no ThreadLocal, no reflection
- Eliminates the need for camel-headersmap in most cases

https://github.com/apache/camel/pull/23766



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to