If the last secondary instance of a peer is deleted (detected by the new
peer memory value being equal to zero), then the pair (pdx, 0) should be
deleted completely. This is not optimization per se, but rather cleanup
(the speedup is at most a percent, and only in some corner cases).
old_peers = peers t
old_peem = P.find pnode old_peers
new_peem = old_peem - Instance.mem inst
- new_peers = P.add pnode new_peem old_peers
+ new_peers = if new_peem > 0
+ then P.add pnode new_peem old_peers
+ else P.remove pnode old_peers
old_rmem = rMem t
new_rmem = if old_peem < old_rmem
then old_rmem