mirror of
https://github.com/tauri-apps/tauri.git
synced 2026-02-06 09:36:53 +00:00
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>
This commit is contained in:
parent
f7c083cd41
commit
9f0306fbcc
@ -57,7 +57,7 @@ fn copy_binaries(
|
||||
binaries: ResourcePaths,
|
||||
target_triple: &str,
|
||||
path: &Path,
|
||||
package_name: Option<&String>,
|
||||
package_name: Option<&str>,
|
||||
) -> Result<()> {
|
||||
for src in binaries {
|
||||
let src = src?;
|
||||
@ -529,7 +529,7 @@ pub fn try_build(attributes: Attributes) -> Result<()> {
|
||||
ResourcePaths::new(&external_binaries(paths, &target_triple, &target), true),
|
||||
&target_triple,
|
||||
target_dir,
|
||||
manifest.package.as_ref().map(|p| &p.name),
|
||||
manifest.package.as_ref().map(|p| p.name.as_ref()),
|
||||
)?;
|
||||
}
|
||||
|
||||
@ -587,21 +587,19 @@ pub fn try_build(attributes: Attributes) -> Result<()> {
|
||||
use semver::Version;
|
||||
use tauri_winres::{VersionInfo, WindowsResource};
|
||||
|
||||
fn find_icon<F: Fn(&&String) -> bool>(config: &Config, predicate: F, default: &str) -> PathBuf {
|
||||
let icon_path = config
|
||||
.bundle
|
||||
.icon
|
||||
.iter()
|
||||
.find(|i| predicate(i))
|
||||
.cloned()
|
||||
.unwrap_or_else(|| default.to_string());
|
||||
icon_path.into()
|
||||
}
|
||||
|
||||
let window_icon_path = attributes
|
||||
.windows_attributes
|
||||
.window_icon_path
|
||||
.unwrap_or_else(|| find_icon(&config, |i| i.ends_with(".ico"), "icons/icon.ico"));
|
||||
.unwrap_or_else(|| {
|
||||
config
|
||||
.bundle
|
||||
.icon
|
||||
.iter()
|
||||
.find(|i| i.ends_with(".ico"))
|
||||
.map(AsRef::as_ref)
|
||||
.unwrap_or("icons/icon.ico")
|
||||
.into()
|
||||
});
|
||||
|
||||
let mut res = WindowsResource::new();
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user