CAMEL-23693: Optimize CaseInsensitiveMap hash for ASCII keys#23779
Conversation
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|
🌟 Thank you for your contribution to the Apache Camel project! 🌟 🐫 Apache Camel Committers, please review the following items:
|
|
🧪 CI tested the following changed modules:
|
davsclaus
left a comment
There was a problem hiding this comment.
Clean performance follow-up to #23766. The ASCII fast-path (c += 32 for A-Z) is correct and produces identical hash values as the previous Character.toLowerCase(Character.toUpperCase(c)) for ASCII, with full Unicode fallback for non-ASCII. Single-hash put() and remove() eliminate redundant computations on the hot path. CI is green, existing tests cover correctness.
This review does not replace specialized AI review tools (CodeRabbit, Sourcery) or static analysis (SonarCloud).
This review was generated by an AI agent and may contain inaccuracies. Please verify all suggestions before applying.
CAMEL-23693
Summary
Optimize the
CaseInsensitiveMaphash function and eliminate redundant hash computations introduced in CAMEL-23691.c += 32forA-Zinstead ofCharacter.toLowerCase(Character.toUpperCase(c))per character. Full Unicode two-step fold only for non-ASCII (c >= 128)put(): compute hash once, reuse for deduplication lookup, find, and bucket insertion (was 3 separate hash computations)remove(): inline chain walk with one hash computation (was 2)Benchmark (18 typical headers, 2M iterations)
Test plan
CaseInsensitiveMapTest— 32 tests passDefaultMessageHeaderTest— 38 tests pass