some clippy::performance fixes

use vec![] instead of Vec::new() +  push()
avoid redundant clones
use chars instead of &str for single char patterns in ends_with() and starts_with()
allocate some Vecs with capacity to avoid unneccessary resizing
This commit is contained in:
Matthias Krüger 2021-03-15 10:15:08 +01:00
parent de36027541
commit cad617bba0
9 changed files with 13 additions and 19 deletions

View file

@ -33,7 +33,7 @@ pub(crate) fn read_info(dylib_path: &Path) -> io::Result<RustCInfo> {
}
let version_part = items.next().ok_or(err!("no version string"))?;
let mut version_parts = version_part.split("-");
let mut version_parts = version_part.split('-');
let version = version_parts.next().ok_or(err!("no version"))?;
let channel = version_parts.next().unwrap_or_default().to_string();
@ -51,7 +51,7 @@ pub(crate) fn read_info(dylib_path: &Path) -> io::Result<RustCInfo> {
let date = date[0..date.len() - 2].to_string();
let version_numbers = version
.split(".")
.split('.')
.map(|it| it.parse::<usize>())
.collect::<Result<Vec<_>, _>>()
.map_err(|_| err!("version number error"))?;