Skip to content

Optimize message list traversal - #707

Merged
arturobernalg merged 1 commit into
apache:masterfrom
arturobernalg:optimize-message-support-list-traversal
Sep 30, 2026
Merged

arturobernalg merged 1 commit into
apache:masterfrom
arturobernalg:optimize-message-support-list-traversal

Conversation

@arturobernalg

Copy link
Copy Markdown
Member

MessageSupport accepts List instances but currently uses the same traversal strategy regardless of the underlying list implementation.

This change uses indexed access for RandomAccess lists and sequential iteration otherwise, avoiding repeated traversal for lists such as LinkedList while preserving the existing fast path for ArrayList.

JMH results:

Benchmark List Entries Current Proposed
formatTokens ArrayList 256 1018.728 ns/op 1030.194 ns/op
formatTokens LinkedList 256 12376.211 ns/op 1132.492 ns/op
formatElements ArrayList 256 13267.483 ns/op 11482.600 ns/op
formatElements LinkedList 256 36706.158 ns/op 11269.578 ns/op

The change is limited to list traversal in formatTokens, formatElements, and formatParameters.

Use indexed access for random-access lists.
Use sequential iteration for other list implementations.
@arturobernalg
arturobernalg requested a review from ok2c September 29, 2026 04:08
@arturobernalg
arturobernalg merged commit 5aa2898 into apache:master Sep 30, 2026
20 of 21 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants