Merge pull request 'A few patches' (#2510) from Robin-patch-1 into develop

Reviewed-on: MapComplete/MapComplete#2510
Reviewed-by: Pieter Vander Vennet <pietervdvn@posteo.net>
This commit is contained in:
Pieter Vander Vennet 2025-08-28 20:33:00 +00:00
commit c30d52c5f4
22 changed files with 986 additions and 79 deletions

View file

@ -314,6 +314,14 @@ export class And<T extends TagsFilter = TagsFilter> extends TagsFilter {
for (let j = i + 1; j < optimized.length; j++) {
const ti = optimized[i]
const tj = optimized[j]
if (
!ti ||
!tj ||
typeof ti.shadows !== "function" ||
typeof tj.shadows !== "function"
) {
continue
}
if (ti.shadows(tj)) {
// if 'ti' is true, this implies 'tj' is always true as well.
// if 'ti' is false, then 'tj' might be true or false
@ -322,6 +330,7 @@ export class And<T extends TagsFilter = TagsFilter> extends TagsFilter {
// If 'ti' is true, then 'tj' will be true too and 'tj' can be ignored
// If 'ti' is false, then the entire expression will be false and it doesn't matter what 'tj' yields
optimized.splice(j, 1)
j--
} else if (tj.shadows(ti)) {
optimized.splice(i, 1)
i--