Remove some unneeded heap allocs#6008
Open
joshuamegnauth54 wants to merge 1 commit intodeltachat:mainfrom
Open
Remove some unneeded heap allocs#6008joshuamegnauth54 wants to merge 1 commit intodeltachat:mainfrom
joshuamegnauth54 wants to merge 1 commit intodeltachat:mainfrom
Conversation
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.
1d4f9aa to
b5c2266
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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_stris infallible so it would never return an error.I force pushed to fix the
cargo fmtcheck failing. It doesn't seem like the fix is related to this patch though.