These busy loops burn CPU cycles without doing anything. It is almost always a
better idea to panic!
than to have a busy loop.
.bytes().count()
RS-P1001.bytes().count()
is better written as .len()
which is easier to read and more performant.
.bytes().nth(..)
RS-P1002.bytes().nth(..)
is better written as .as_bytes().get(..)
which is more performant.
Arc<RwLock<HashMap<K, V>>>
RS-P1003Arc<RwLock<HashMap<K, V>>>
has performance concerns, the dashmap
crate provides a much better alternative to concurrent hashmaps.
Hence, Arc<RwLock<HashMap<K, V>>>
is better off replaced by Arc<DashMap<K, V>>
from the dashmap
crate.
.trim()
followed by .split_whitespace()
RS-P1005.split_whitespace()
produces an iterator with preceding and trailing
whitespace removed. Thus, s.trim().split_whitespace()
is equivalent to just
s.split_whitespace()
.