mirror of
https://github.com/edera-dev/sprout.git
synced 2025-12-19 10:30:17 +00:00
chore(perf): replace some string replacement and comparison with characters for performance
This commit is contained in:
@@ -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<String> {
|
||||
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.
|
||||
|
||||
@@ -37,7 +37,7 @@ pub fn device_path_root(path: &DevicePath) -> Result<String> {
|
||||
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<String> {
|
||||
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<Resol
|
||||
it.to_string(DisplayOnly(false), AllowShortcuts(false))
|
||||
.unwrap_or_default()
|
||||
})
|
||||
.map(|it| it.to_string().contains("("))
|
||||
.map(|it| it.to_string().contains('('))
|
||||
.unwrap_or(false);
|
||||
if !path_has_device {
|
||||
let mut input = input.to_string();
|
||||
if !input.starts_with("\\") {
|
||||
if !input.starts_with('\\') {
|
||||
input.insert(0, '\\');
|
||||
}
|
||||
input.insert_str(
|
||||
|
||||
Reference in New Issue
Block a user