From 0b0b4dc19df0ef02da750f194620cdd0fdb96fa4 Mon Sep 17 00:00:00 2001 From: Alex Zenla Date: Fri, 24 Oct 2025 18:59:15 -0700 Subject: [PATCH] chore(perf): replace some string replacement and comparison with characters for performance --- src/generators/bls/entry.rs | 4 ++-- src/utils.rs | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/generators/bls/entry.rs b/src/generators/bls/entry.rs index 18d568d..88790cc 100644 --- a/src/generators/bls/entry.rs +++ b/src/generators/bls/entry.rs @@ -99,7 +99,7 @@ impl BlsEntry { self.linux .clone() .or(self.efi.clone()) - .map(|path| path.replace("/", "\\").trim_start_matches("\\").to_string()) + .map(|path| path.replace('/', "\\").trim_start_matches('\\').to_string()) } /// Fetches the path to an initrd to pass to the kernel, if any. @@ -107,7 +107,7 @@ impl BlsEntry { pub fn initrd_path(&self) -> Option { self.initrd .clone() - .map(|path| path.replace("/", "\\").trim_start_matches("\\").to_string()) + .map(|path| path.replace('/', "\\").trim_start_matches('\\').to_string()) } /// Fetches the options to pass to the kernel, if any. diff --git a/src/utils.rs b/src/utils.rs index 24edafd..5d79fd6 100644 --- a/src/utils.rs +++ b/src/utils.rs @@ -37,7 +37,7 @@ pub fn device_path_root(path: &DevicePath) -> Result { let item = item.to_string(DisplayOnly(false), AllowShortcuts(false)); if item .as_ref() - .map(|item| item.to_string().contains("(")) + .map(|item| item.to_string().contains('(')) .unwrap_or(false) { Some(item.unwrap_or_default()) @@ -62,7 +62,7 @@ pub fn device_path_subpath(path: &DevicePath) -> Result { let item = item.to_string(DisplayOnly(false), AllowShortcuts(false)); if item .as_ref() - .map(|item| item.to_string().contains("(")) + .map(|item| item.to_string().contains('(')) .unwrap_or(false) { None @@ -104,11 +104,11 @@ pub fn resolve_path(default_root_path: &DevicePath, input: &str) -> Result