Improve optimizations

This commit is contained in:
Pieter Vander Vennet 2024-07-29 19:05:10 +02:00
parent 82b25bd2a6
commit d98816212d
2 changed files with 14 additions and 6 deletions

View file

@ -137,15 +137,13 @@ export class Tag extends TagsFilter {
* new Tag("key","value").shadows(new And([new Tag("x","y"), new RegexTag("a","b", true)]) // => false
*/
shadows(other: TagsFilter): boolean {
if (other["key"] !== this.key) {
return false
}
if (other instanceof Tag) {
// Other.key === this.key
return other.value === this.value
return other.key === this.key && other.value === this.value
}
if (other instanceof RegexTag) {
return other.matchesProperties({ [this.key]: this.value })
if(other.key === this.key || !other.invert){
return other.matchesProperties({ [this.key]: this.value })
}
}
return false
}