Skip to content

Replace some + Count Check with atLeastOne and atLeastTwo Matchers #3415

@hatyo

Description

@hatyo

Refactor existing code that currently uses the some collection matcher combined with a subsequent count check to verify the number of elements satisfying a condition. We should replace these instances with the newly introduced atLeastOne and atLeastTwo matchers (introduced in #3411).

Switching to the atLeastOne and atLeastTwo matchers offers two key benefits:

Performance: By moving the element count condition to the preamble of the matching rule, we can reduce the number of false positives and improve overall matching performance. This is because the matcher can short-circuit the evaluation if the minimum required number of elements is not found.
Code Readability: Using the dedicated atLeastOne and atLeastTwo matchers makes the intent of the code clearer and more concise, improving readability and maintainability. It directly expresses the requirement for a minimum number of matching elements.

Metadata

Metadata

Assignees

Labels

enhancementNew feature or requestperformancePerformance issuesplannerRelated to the query planner

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions