-
-
Notifications
You must be signed in to change notification settings - Fork 354
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
More Keyword Tweaks #6694
base: dev/feature
Are you sure you want to change the base?
More Keyword Tweaks #6694
Conversation
ChoiceKeywords add support for more advanced choice groups
Set<Set<Keyword>> choices = ((ChoicePatternElement) next).getPatternElements().stream() | ||
.map(element -> buildKeywords(element, finalStarting, finalDepth)) | ||
.map(ImmutableSet::copyOf) | ||
.collect(Collectors.toSet()); | ||
if (choices.stream().noneMatch(Collection::isEmpty)) // each choice must have a keyword for this to work |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks kind of messy and inefficient, especially all the repeated collection copying. Maybe it would be faster to do it properly?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I could use Set<Keyword[]> rather than a Set of Sets
Description
This PR makes some tweaks to the Keyword class to improve simplicity.
I have removed the
flatten
utility method. Instead, a recursive approach is taken for building keyword(s) from a choice pattern (it will only go one level down from the root for choices). I have replacedGroupKeyword
withChoiceKeyword
is a set of the keywords for each choice. The same idea follows that one of the sets of keywords must apply for the input expression to match.I've also added some overrides to the keyword implementations (idk about the hashcode implementations).
Some brief testing indicated a possible minor performance increase, though the goal is really only to maintain performance (while improving the implementation).
Target Minecraft Versions: any
Requirements: none
Related Issues: none