Simplify predicate concatenation in JpqlQueryBuilder.and(List) - #4352
Open
JunggiKim wants to merge 1 commit into
Open
Simplify predicate concatenation in JpqlQueryBuilder.and(List)#4352JunggiKim wants to merge 1 commit into
JunggiKim wants to merge 1 commit into
Conversation
JpqlQueryBuilder.and(List) combined predicates by repeatedly calling Predicate.and(Predicate), and each of those calls flattened everything accumulated so far into a new list, which makes the element copies quadratic in the number of predicates. AndPredicate.of(List) already flattens an entire list in one pass and or(List) directly below already delegates to OrPredicate.of(List), so and(List) now delegates the same way. The empty and single-element cases stay explicit so that the returned instance is the same as before: an empty list returns null and a single predicate is returned unchanged rather than wrapped in an AndPredicate. Signed-off-by: Junggi Kim <kimjg2477@gmail.com>
JunggiKim
force-pushed
the
issue/simplify-jpql-and
branch
from
September 11, 2026 06:22
d7beab6 to
57e1001
Compare
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.
JpqlQueryBuilder.and(List)combines predicates by repeatedly callingPredicate.and(Predicate), and each of those calls flattens everything accumulated so far into a new list, so the element copies are quadratic in the number of predicates.AndPredicate.of(List)already flattens a list in one pass andor(List), directly below, already delegates toOrPredicate.of(List), soand(List)now delegates the same way. The empty and single-element cases stay explicit to keep the returned instance the same as before.The only caller is
KeysetScrollSpecification, where the list holds one predicate per keyset sort key; in the queries the tests generate that is one to four predicates. One thing does change for input that caller never produces: anullnext to another predicate used to be dropped, or to fail insideList.of, and now throws when the predicate is rendered.The added tests pass against the previous implementation too, and the module test suite passes before and after.