HomePhabricator

Use std::unordered_set instead of std::vector in IsEvicted()

Description

Use std::unordered_set instead of std::vector in IsEvicted()

Summary:
An unordered set can tell if an element is present in ~O(1) time (constant on
average, worst case linear to the size of the container), which speeds up and
simplifies the lookup in IsEvicted().

Co-authored-by: Vasil Dimov <vd@FreeBSD.org>

This is a backport of core#20197 [3/6]
https://github.com/bitcoin/bitcoin/pull/20197/commits/ca63b53ecdf377ce777fd959d400748912266748
Depends on D10976

Test Plan: ninja check

Reviewers: #bitcoin_abc, Fabien

Reviewed By: #bitcoin_abc, Fabien

Differential Revision: https://reviews.bitcoinabc.org/D10977

Details

Provenance
Jon Atack <jon@atack.com>Authored on Feb 28 2021, 14:53
PiRKCommitted on Feb 4 2022, 10:59
PiRKPushed on Feb 4 2022, 10:59
Reviewer
Restricted Project
Differential Revision
D10977: Use std::unordered_set instead of std::vector in IsEvicted()
Parents
rABCe17e1b20619e: Move peer eviction tests to a separate test file
Branches
Unknown
Tags
Unknown