Skip to content

Conversation

@MahdiBM
Copy link
Contributor

@MahdiBM MahdiBM commented Oct 16, 2025

Motivation:

ByteBuffer.firsIndex is of suboptimal performance.
The default Collection implementations don't go through any "magic underscored" functions like _customIndexOfEquatableElement.

Modifications:

Manually implement firstIndex(where:).

Result:

Basically free performance boost. 2x+ boost even for not big buffers of a few hundred bytes.

There are some usage of this function in BufferedReader. Those will become much faster.
Also this function is used in ByteBufferView.trim(limitingElements:).

Also makes #3411 stuff faster. See: #3411 (comment)

@MahdiBM
Copy link
Contributor Author

MahdiBM commented Oct 16, 2025

cc @glbrntt @Lukasa

@glbrntt glbrntt added the 🆕 semver/minor Adds new public API. label Oct 17, 2025
@glbrntt glbrntt enabled auto-merge (squash) October 17, 2025 06:53
@glbrntt glbrntt merged commit 767ea9e into apple:main Oct 17, 2025
58 of 63 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

🆕 semver/minor Adds new public API.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants