Skip to content

Commit

Permalink
Optimize by storing intersection
Browse files Browse the repository at this point in the history
  • Loading branch information
bugarela committed Oct 4, 2023
1 parent 355342d commit 017ef05
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions quint/src/effects/base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -333,9 +333,10 @@ export function unifyEntities(va: Entity, vb: Entity): Either<ErrorTree, Substit
} else if (v1.kind === 'concrete' && v2.kind === 'union') {
return unifyEntities(v2, v1)
} else if (v1.kind === 'union' && v2.kind === 'union') {
if (intersectionWith(v1.entities, v2.entities, isEqual).length > 0) {
const s1 = { ...v1, entities: differenceWith(v1.entities, v2.entities, isEqual) }
const s2 = { ...v2, entities: differenceWith(v2.entities, v1.entities, isEqual) }
const intersection = intersectionWith(v1.entities, v2.entities, isEqual)
if (intersection.length > 0) {
const s1 = { ...v1, entities: differenceWith(v1.entities, intersection, isEqual) }
const s2 = { ...v2, entities: differenceWith(v2.entities, intersection, isEqual) }

// There was an intersection, try to unify the remaining entities
return unifyEntities(s1, s2)
Expand Down

0 comments on commit 017ef05

Please sign in to comment.