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.
Problem
In #8316, a feature was implemented so that the Origin of a syntax can be automatically determined (as what addon is providing it) if not set. However, this change means that our rule that when two syntaxes share a Priority, any syntax from Skript itself comes first is leading to some slowdowns. This is due to the fact that Skript has some costly patterns that are using default priorities (rather than forcing themselves to occur later).
Additionally, the
patternsproperty ofSyntaxInfois currently represented by aCollection. However, ordering is an important part of writing syntax (e.g.matchedPatternininit), meaning the current typing is too loose.Solution
I have implemented a basic system to estimate the priority of a Syntax based on the definitions of the predefined (standard) priorities:
SIMPLEmeans the pattern contains no expressionsCOMBINEDmeans the pattern contains one or more expressionsPATTERN_MATCHES_EVERYTHINGmeans the pattern contains multiple expressions directly next to each other (e.g. EffTree:(grow|create|generate) %structuretype% %directions% %locations%)This check is not intended to be extensive, but to instead cover most general use cases (i.e. you should not generally have to provide a priority). Of course, for specific patterns (maybe where regular expressions are involved, for example), it is still recommended explicitly specify a priority.
Now that we are using Java 21,
SequencedCollectionis now available to us, and it is exactly what we need for something likepatterns, where ordering is important, but random access is not. I have updatedpatternsto use this type. I have also updatedsinceanddescriptionofBukkitSyntaxInfos.Eventto use this, as ordering is relevant for those two properties. This should not impact existing code sinceSequencedCollectionis a subtype ofCollection.Testing Completed
Local testing demonstrated significant improvements for affected syntax. There does not seem to be any negative impact, though I would like to test with more expansive setups.
Supporting Information
n/a
Completes: none
Related: none
AI assistance: none