Skip to content

Remove some unneeded heap allocs#6008

Open
joshuamegnauth54 wants to merge 1 commit intodeltachat:mainfrom
joshuamegnauth54:elide-some-allocs
Open

Remove some unneeded heap allocs#6008
joshuamegnauth54 wants to merge 1 commit intodeltachat:mainfrom
joshuamegnauth54:elide-some-allocs

Conversation

@joshuamegnauth54
Copy link
Contributor

@joshuamegnauth54 joshuamegnauth54 commented Feb 1, 2026

This is in no way exhaustive, but if it's accepted I can fix a few of the other simple cases I found as well.

Most of the fixes for this batch involve taking ownership of a &str to create a PathBuf or String. In the fixed cases, a borrowed Path or the &str or Cow could be used directly. In other cases, Strings were cloned to make PathBufs instead of consumed directly. SafePathBufs cloned PathBufs instead of using them directly as well.

I removed a few unneeded from_strs too. PathBuf::from_str is infallible so it would never return an error.

I force pushed to fix the cargo fmt check failing. It doesn't seem like the fix is related to this patch though.

This is in no way exhaustive. Most of the fixes involve taking ownership
of a &str to create a PathBuf or String. In the fixed cases, a borrowed
Path or the &str or Cow could be used directly. In other cases, Strings
were cloned to make PathBufs instead of consumed directly. SafePathBufs
cloned PathBufs instead of using them directly as well.

I removed a few unneeded from_strs too. `PathBuf::from_str` is
infallible so it would never return an error.
@WofWca WofWca added the Runtime: Tauri Issue affecting the tauri runtime specifically label Feb 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Runtime: Tauri Issue affecting the tauri runtime specifically

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants