Skip to content

Commit 9f0306f

Browse files
refactor: rewrite some &String to &str (#14857)
* perf(tauri-build): refactor find_icon to use &str to remove unnecessary clones * refactor(perf-tauri-build): remove obsolete changelog for find_icon refactor * refactor(tauri-build): inline find_icon logic to simplify window icon path retrieval * refactor(context): update find_icon predicate to use &str * refactor(context): simplify predicate in find_icon to accept &&String * Update crates/tauri-build/src/lib.rs Co-authored-by: Tony <68118705+Legend-Master@users.noreply.github.com> --------- Co-authored-by: Tony <68118705+Legend-Master@users.noreply.github.com>
1 parent f7c083c commit 9f0306f

File tree

1 file changed

+12
-14
lines changed

1 file changed

+12
-14
lines changed

crates/tauri-build/src/lib.rs

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ fn copy_binaries(
5757
binaries: ResourcePaths,
5858
target_triple: &str,
5959
path: &Path,
60-
package_name: Option<&String>,
60+
package_name: Option<&str>,
6161
) -> Result<()> {
6262
for src in binaries {
6363
let src = src?;
@@ -529,7 +529,7 @@ pub fn try_build(attributes: Attributes) -> Result<()> {
529529
ResourcePaths::new(&external_binaries(paths, &target_triple, &target), true),
530530
&target_triple,
531531
target_dir,
532-
manifest.package.as_ref().map(|p| &p.name),
532+
manifest.package.as_ref().map(|p| p.name.as_ref()),
533533
)?;
534534
}
535535

@@ -587,21 +587,19 @@ pub fn try_build(attributes: Attributes) -> Result<()> {
587587
use semver::Version;
588588
use tauri_winres::{VersionInfo, WindowsResource};
589589

590-
fn find_icon<F: Fn(&&String) -> bool>(config: &Config, predicate: F, default: &str) -> PathBuf {
591-
let icon_path = config
592-
.bundle
593-
.icon
594-
.iter()
595-
.find(|i| predicate(i))
596-
.cloned()
597-
.unwrap_or_else(|| default.to_string());
598-
icon_path.into()
599-
}
600-
601590
let window_icon_path = attributes
602591
.windows_attributes
603592
.window_icon_path
604-
.unwrap_or_else(|| find_icon(&config, |i| i.ends_with(".ico"), "icons/icon.ico"));
593+
.unwrap_or_else(|| {
594+
config
595+
.bundle
596+
.icon
597+
.iter()
598+
.find(|i| i.ends_with(".ico"))
599+
.map(AsRef::as_ref)
600+
.unwrap_or("icons/icon.ico")
601+
.into()
602+
});
605603

606604
let mut res = WindowsResource::new();
607605

0 commit comments

Comments
 (0)