raft-rs icon indicating copy to clipboard operation
raft-rs copied to clipboard

Try to reduce clones with a library like rental/owning_ref

Open Hoverbear opened this issue 6 years ago • 2 comments
trafficstars

As mentioned in https://github.com/tikv/tikv/pull/4640#discussion_r281434168, owning_ref might be a useful crate for us to try.

Investigate the library and look for appropriate places where this library can be used to reduce clones.

https://crates.io/crates/owning_ref

Caution: Several commenters expressed concern for the library, noting it seemed relatively unmaintained (https://github.com/tikv/tikv/pull/4640#discussion_r282646161) but rental may also help. (https://github.com/tikv/tikv/pull/4640#pullrequestreview-234099670)

Hoverbear avatar Jun 14 '19 20:06 Hoverbear

These might be good things to try, for sure. I would also like to try just using some explicit lifetimes. Usually (not always of course) refactoring code to fit with lifetimes results in better code, even if it is a big overhaul.

nrc avatar Jun 15 '19 05:06 nrc

@BusyJay found a way to reduce the clone of entries, but the benchmark result was not improved largely.

Please send the PR @BusyJay

siddontang avatar Jun 15 '19 12:06 siddontang