Clean up empty entries in subscription-matches

This commit is contained in:
Tony Garnock-Jones 2019-05-20 22:07:02 +01:00
parent b5bae7f8f6
commit 5f766d5b12
1 changed files with 3 additions and 1 deletions

View File

@ -263,7 +263,9 @@
(define old-matches (subscription-matches sub))
(define old-match-holders (hash-ref old-matches captures set))
(define new-match-holders (set-remove old-match-holders linkid))
(define new-matches (hash-set old-matches captures new-match-holders))
(define new-matches (if (set-empty? new-match-holders)
(hash-remove old-matches captures)
(hash-set old-matches captures new-match-holders)))
(store-sub! (struct-copy subscription sub [matches new-matches]))
(match (set-count new-match-holders)
[0 (for [((peer peer-subid) (in-hash (subscription-holders sub)))]