mirror of
https://github.com/unisonweb/unison.git
synced 2024-09-21 07:17:25 +03:00
optimize Names.contains
This commit is contained in:
parent
0f2fc7d15d
commit
0ae88ea47b
@ -381,10 +381,13 @@ difference a b = Names (R.difference (terms a) (terms b))
|
||||
(R.difference (types a) (types b))
|
||||
|
||||
contains :: Names -> Reference -> Bool
|
||||
contains names r =
|
||||
-- this check makes `contains` O(n) instead of O(log n)
|
||||
(Set.member r . Set.map Referent.toReference . R.ran) (terms names)
|
||||
|| R.memberRan r (types names)
|
||||
contains names =
|
||||
\r -> Set.member r termsReferences || R.memberRan r (types names)
|
||||
where
|
||||
-- this check makes `contains` O(n) instead of O(log n)
|
||||
termsReferences :: Set Reference
|
||||
termsReferences =
|
||||
Set.map Referent.toReference (R.ran (terms names))
|
||||
|
||||
-- | filters out everything from the domain except what's conflicted
|
||||
conflicts :: Names -> Names
|
||||
|
Loading…
Reference in New Issue
Block a user