graph-store: no need to iterate through whole list if we find a single duplicate

This commit is contained in:
Logan Allen 2020-12-11 18:13:47 -06:00
parent 78cf4443c2
commit 386997475b

View File

@ -316,13 +316,10 @@
++ check-for-duplicates ++ check-for-duplicates
|= [=graph:store nodes=(set index:store)] |= [=graph:store nodes=(set index:store)]
^- ? ^- ?
=/ has-duplicates %.n
=/ node-list ~(tap in nodes) =/ node-list ~(tap in nodes)
|- |-
?~ node-list ?~ node-list %.n
has-duplicates ?: (has-node graph i.node-list) %.y
=. has-duplicates
|(has-duplicates (has-node graph i.node-list))
$(node-list t.node-list) $(node-list t.node-list)
:: ::
++ has-node ++ has-node