.bytes().count()
RS-P1001.bytes().count()
is better written as .len()
which is easier to read and more performant.
.len()
refers to the length property of str
and is a constant-time operation. .bytes().count()
iterates over the bytes in the string and is a linear-time operation.
Replace the call to .bytes().count()
with .len()
for &str
.
"random str".bytes().count()
"random str".len()