Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions .changes/perf-remove-needless-clone.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
"tauri-bundler": patch:perf
"tauri-cli": patch:perf
"tauri-macos-sign": patch:perf
"tauri": patch:perf
---

perf: remove needless clones in various files for improved performance. No user facing changes.
24 changes: 6 additions & 18 deletions crates/tauri-bundler/src/bundle/macos/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,16 +65,12 @@ pub fn bundle_project(settings: &Settings) -> crate::Result<Vec<PathBuf>> {
log::info!(action = "Bundling"; "{} ({})", app_product_name, app_bundle_path.display());

if app_bundle_path.exists() {
fs::remove_dir_all(&app_bundle_path).fs_context(
"failed to remove old app bundle",
app_bundle_path.to_path_buf(),
)?;
fs::remove_dir_all(&app_bundle_path)
.fs_context("failed to remove old app bundle", &app_bundle_path)?;
}
let bundle_directory = app_bundle_path.join("Contents");
fs::create_dir_all(&bundle_directory).fs_context(
"failed to create bundle directory",
bundle_directory.to_path_buf(),
)?;
fs::create_dir_all(&bundle_directory)
.fs_context("failed to create bundle directory", &bundle_directory)?;

let resources_dir = bundle_directory.join("Resources");
let bin_dir = bundle_directory.join("MacOS");
Expand Down Expand Up @@ -459,20 +455,12 @@ fn copy_frameworks_to_bundle(
) -> crate::Result<Vec<SignTarget>> {
let mut paths = Vec::new();

let frameworks = settings
.macos()
.frameworks
.as_ref()
.cloned()
.unwrap_or_default();
let frameworks = settings.macos().frameworks.clone().unwrap_or_default();
if frameworks.is_empty() {
return Ok(paths);
}
let dest_dir = bundle_directory.join("Frameworks");
fs::create_dir_all(&dest_dir).fs_context(
"failed to create Frameworks directory",
dest_dir.to_path_buf(),
)?;
fs::create_dir_all(&dest_dir).fs_context("failed to create Frameworks directory", &dest_dir)?;
for framework in frameworks.iter() {
if framework.ends_with(".framework") {
let src_path = PathBuf::from(framework);
Expand Down
12 changes: 4 additions & 8 deletions crates/tauri-bundler/src/bundle/macos/ios.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,15 +44,11 @@ pub fn bundle_project(settings: &Settings) -> crate::Result<Vec<PathBuf>> {
log::info!(action = "Bundling"; "{} ({})", app_product_name, app_bundle_path.display());

if app_bundle_path.exists() {
fs::remove_dir_all(&app_bundle_path).fs_context(
"failed to remove old app bundle",
app_bundle_path.to_path_buf(),
)?;
fs::remove_dir_all(&app_bundle_path)
.fs_context("failed to remove old app bundle", &app_bundle_path)?;
}
fs::create_dir_all(&app_bundle_path).fs_context(
"failed to create bundle directory",
app_bundle_path.to_path_buf(),
)?;
fs::create_dir_all(&app_bundle_path)
.fs_context("failed to create bundle directory", &app_bundle_path)?;

for src in settings.resource_files() {
let src = src?;
Expand Down
2 changes: 1 addition & 1 deletion crates/tauri-cli/src/acl/permission/ls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ pub fn command(options: Options) -> Result<()> {

if acl_manifests_path.exists() {
let plugin_manifest_json = read_to_string(&acl_manifests_path)
.fs_context("failed to read plugin manifest", acl_manifests_path.clone())?;
.fs_context("failed to read plugin manifest", acl_manifests_path)?;
let acl = serde_json::from_str::<BTreeMap<String, Manifest>>(&plugin_manifest_json)
.context("failed to parse plugin manifest as JSON")?;

Expand Down
4 changes: 2 additions & 2 deletions crates/tauri-cli/src/dev/builtin_dev_server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -155,9 +155,9 @@ fn inject_address(html_bytes: Vec<u8>, address: &SocketAddr) -> Vec<u8> {
}

fn fs_read_scoped(path: PathBuf, scope: &Path) -> crate::Result<Vec<u8>> {
let path = dunce::canonicalize(&path).fs_context("failed to canonicalize path", path.clone())?;
let path = dunce::canonicalize(&path).fs_context("failed to canonicalize path", path)?;
if path.starts_with(scope) {
std::fs::read(&path).fs_context("failed to read file", path.clone())
std::fs::read(&path).fs_context("failed to read file", &path)
} else {
crate::error::bail!("forbidden path")
}
Expand Down
6 changes: 2 additions & 4 deletions crates/tauri-cli/src/helpers/updater_signature.rs
Original file line number Diff line number Diff line change
Expand Up @@ -146,10 +146,8 @@ where
std::fs::write(&signature_path, encoded_signature.as_bytes())
.fs_context("failed to write signature file", signature_path.clone())?;
Ok((
fs::canonicalize(&signature_path).fs_context(
"failed to canonicalize signature file",
signature_path.clone(),
)?,
fs::canonicalize(&signature_path)
.fs_context("failed to canonicalize signature file", &signature_path)?,
signature_box,
))
}
Expand Down
4 changes: 2 additions & 2 deletions crates/tauri-cli/src/init.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,8 @@ impl Options {
let package_json_path = PathBuf::from(&self.directory).join("package.json");

let init_defaults = if package_json_path.exists() {
let package_json_text = read_to_string(&package_json_path)
.fs_context("failed to read", package_json_path.clone())?;
let package_json_text =
read_to_string(&package_json_path).fs_context("failed to read", &package_json_path)?;
let package_json: crate::PackageJson =
serde_json::from_str(&package_json_text).context("failed to parse JSON")?;
let (framework, _) = infer_framework(&package_json_text);
Expand Down
2 changes: 1 addition & 1 deletion crates/tauri-cli/src/interface/rust/desktop.rs
Original file line number Diff line number Diff line change
Expand Up @@ -335,7 +335,7 @@ fn rename_app(
""
};
let new_path = bin_path.with_file_name(format!("{main_binary_name}{extension}"));
fs::rename(&bin_path, &new_path).fs_context("failed to rename app binary", bin_path.clone())?;
fs::rename(&bin_path, &new_path).fs_context("failed to rename app binary", bin_path)?;
Ok(new_path)
} else {
Ok(bin_path)
Expand Down
2 changes: 1 addition & 1 deletion crates/tauri-cli/src/interface/rust/manifest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,7 @@ pub fn rewrite_manifest(config: &Config) -> crate::Result<(Manifest, bool)> {

if persist && original_manifest_str != new_manifest_str {
std::fs::write(&manifest_path, new_manifest_str)
.fs_context("failed to rewrite Cargo manifest", manifest_path.clone())?;
.fs_context("failed to rewrite Cargo manifest", &manifest_path)?;
Ok((
Manifest {
inner: manifest,
Expand Down
2 changes: 1 addition & 1 deletion crates/tauri-cli/src/migrate/migrations/v1/manifest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ pub fn migrate(tauri_dir: &Path) -> Result<()> {
migrate_manifest(&mut manifest)?;

std::fs::write(&manifest_path, serialize_manifest(&manifest))
.fs_context("failed to rewrite Cargo manifest", manifest_path.clone())?;
.fs_context("failed to rewrite Cargo manifest", &manifest_path)?;

Ok(())
}
Expand Down
6 changes: 2 additions & 4 deletions crates/tauri-cli/src/migrate/migrations/v2_beta.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,8 @@ pub fn run() -> Result<()> {

migrate_npm_dependencies(frontend_dir)?;

std::fs::write(&manifest_path, serialize_manifest(&manifest)).fs_context(
"failed to rewrite Cargo manifest",
manifest_path.to_path_buf(),
)?;
std::fs::write(&manifest_path, serialize_manifest(&manifest))
.fs_context("failed to rewrite Cargo manifest", &manifest_path)?;

Ok(())
}
Expand Down
2 changes: 1 addition & 1 deletion crates/tauri-cli/src/mobile/ios/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,7 @@ pub fn command(options: Options, noise_level: NoiseLevel) -> Result<BuiltApplica
tempfile::NamedTempFile::new().context("failed to create temporary file")?;

let merged_plist = merge_plist(vec![
export_options_plist_path.clone().into(),
export_options_plist_path.into(),
plist::Value::from(export_options_plist).into(),
])?;
merged_plist
Expand Down
2 changes: 1 addition & 1 deletion crates/tauri-macos-sign/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ fn notarize_inner(
String::from_utf8_lossy(&output.stdout)
)))
} else {
Err(Error::Notarize(log_message.to_string()))
Err(Error::Notarize(log_message))
}
} else {
Err(Error::ParseNotarytoolOutput {
Expand Down
4 changes: 2 additions & 2 deletions crates/tauri/src/path/plugin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ use crate::{
/// <https://github.com/rust-lang/cargo/blob/46fa867ff7043e3a0545bf3def7be904e1497afd/crates/cargo-util/src/paths.rs#L73-L106>
fn normalize_path(path: &Path) -> PathBuf {
let mut components = path.components().peekable();
let mut ret = if let Some(c @ Component::Prefix(..)) = components.peek().cloned() {
let mut ret = if let Some(c @ Component::Prefix(..)) = components.peek().copied() {
components.next();
PathBuf::from(c.as_os_str())
} else {
Expand Down Expand Up @@ -47,7 +47,7 @@ fn normalize_path(path: &Path) -> PathBuf {
/// <https://github.com/rust-lang/cargo/blob/46fa867ff7043e3a0545bf3def7be904e1497afd/crates/cargo-util/src/paths.rs#L73-L106>
fn normalize_path_no_absolute(path: &Path) -> PathBuf {
let mut components = path.components().peekable();
let mut ret = if let Some(c @ Component::Prefix(..)) = components.peek().cloned() {
let mut ret = if let Some(c @ Component::Prefix(..)) = components.peek().copied() {
components.next();
PathBuf::from(c.as_os_str())
} else {
Expand Down
Loading