Skip to content

Conversation

@TheDGOfficial
Copy link
Contributor

Small allocation optimization, VALUES field already existed in the enum so I figured we could use it. Saw it on a Spark report originally.

Screenshot From 2025-09-17 23-14-42

Likely very minor gains to be noticeable. I haven't extensively tested it, but from a quick test the game runs fine with the patch.

I have not checked all the usages of the method to verify the return value is not modified, but modifying an enum's values would be terrible anyways, so returning the same VALUES constant instead of allocating a new array everytime from values() should be safe and the VALUES field already exists, suggesting that this code was just forgotten to be updated to utilize it over values().

I have not checked if any other place could be turned from values() to VALUES, but this was the only code path I saw in my Spark reports.

Testing

  1. /sparkc profiler start --thread * --alloc
  2. Wait for a while, play normally
  3. /sparkc profiler stop
  4. Open result from link, look in "Chunk Render Task Executor" thread

@IThundxr
Copy link
Contributor

VALUES is a private field, you'll need to use a accesswidener/accesstransformer or accessor to even access it.

@TheDGOfficial
Copy link
Contributor Author

VALUES is a private field, you'll need to use a accesswidener/accesstransformer or accessor to even access it.

It compiled and launched fine for me. Looking at the code, it's defined as a public static final field:

public static final ModelQuadFacing[] VALUES = ModelQuadFacing.values();

@IThundxr
Copy link
Contributor

ah yeah, didn't see that properly, $VALUES is the field that's not public and is generated by the compiler

@jellysquid3 jellysquid3 merged commit c8c611a into CaffeineMC:dev Oct 5, 2025
1 check failed
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.

3 participants