1ad69cfc38
Dynamic dispatch forces heap allocation and adds extra overhead. Dynamic casting as in the ones below, lacks compile-time type safety: https://github.com/solana-labs/solana/blob/eeb622c4e/quic-client/src/lib.rs#L172-L175 https://github.com/solana-labs/solana/blob/eeb622c4e/udp-client/src/lib.rs#L52-L55 The commit removes all instances of Any, Box<dyn ...>, and Arc<dyn ...>, and instead uses generic and associated types. There are only two protocols QUIC and UDP; and the code which has to work with both protocols can use a trivial thin enum wrapper. With respect to connection-cache specifically: * connection-cache/ConnectionCache is a single protocol cache which allows to use either QUIC or UDP without any build dependency on the other protocol. * client/ConnectionCache is an enum wrapper around both protocols and can be used in the code which has to work with both QUIC and UDP. Co-authored-by: Tyera Eulberg <tyera@solana.com> |
||
---|---|---|
.. | ||
src | ||
tests | ||
Cargo.toml |