Repository navigation
perf(player): write auth input flags without copying the enum - #512
Merged
Conversation
The PlayerAuthInput translation runs every client tick. It walked PlayerAuthInputData.values(), which allocates a copy of all 66 constants, and checked each one against the player's input set. The input set is an EnumSet, which iterates in declaration order, so iterating it directly writes the same flags in the same order. This removes the array copy and the 66 membership checks per tick. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Collaborator
|
Looks fine @RaphiMC what do you think |
Exterminate5573
approved these changes
Dec 3, 2026
AlexProgrammerDE
marked this pull request as ready for review
December 3, 2026 10:11
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What this changes
The PlayerAuthInput translation runs every client tick. It walked
PlayerAuthInputData.values(), which allocates a copy of all 66 constants,
and checked each one against the player's input set.
The input set is an EnumSet, which iterates in declaration order, so
iterating it directly writes the same flags in the same order. This
removes the array copy and the 66 membership checks per tick.
Co-Authored-By: Claude Opus 5.5 noreply@anthropic.com
This PR contains one patch from StackAnvil's viabedrock stack, applied alone to the pinned upstream base.
Test sources, fixtures, and test-only build configuration stay in StackAnvil's local stack and are excluded from this PR.
Write auth input flags without copying the enum
Design constraint
The packet must keep its layout.
EnumSetiteration follows declaration order, so the new loop writes the same flag count and the same flag values in the same order as the old one.Validation
Limits
I found this by reading the code, not by profiling. It removes one array allocation per tick and does not change behavior.
🤖 Generated with Claude Code