Eagerly parse and compare the shaped recipe output item #115
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.
This PR adds logic to
RecipeLinkwhich engages when theRecipeLinkis holding a shaped recipe (of typeminecraft:crafting_shaped) to speed up the matching process against other shaped recipes.Recipe Links are compared
O(N^2)times against other recipe links of the same type - in ATM10, there are ~70k recipes, with the vast majority being shaped, so then number of comparisons is... probably in the billions, at least (60k^2 is 3.6B).So, to preempt the common case, when a
RecipeLinkfor a shaped recipe is encountered, we parse the output item from the underlyingJsonObject, and preemptively compare it using reference equality.This brings AU's startup time in ATM10 from 20s to 1.6s (12.5x faster // 92% uplift). You could probably optimize this further by pushing the
HolderLookup.Providerdown into theRecipeLinkctor and being able to parse the entireItemStack, but it seems like this gets the supermajority of the cases so there might not be much point.