Skip to content

Commit

Permalink
ref(api): Remove unnecessary collect (#2333)
Browse files Browse the repository at this point in the history
Since we only use the `Vec` created by the `collect` in the loop below,
there is no reason for the collect. Removing the collect prevents an
unnecessary allocation of the `Vec`, and allows the loop instead to
lazily compute the stringified chunks during iteration
  • Loading branch information
szokeasaurusrex authored Jan 7, 2025
1 parent 3638236 commit ace07ee
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions src/api/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -379,11 +379,10 @@ impl Api {
// Curl stores a raw pointer to the stringified checksum internally. We first
// transform all checksums to string and keep them in scope until the request
// has completed. The original iterator is not needed anymore after this.
let stringified_chunks: Vec<_> = chunks
let stringified_chunks = chunks
.into_iter()
.map(T::as_ref)
.map(|&(checksum, data)| (checksum.to_string(), data))
.collect();
.map(|&(checksum, data)| (checksum.to_string(), data));

let mut form = curl::easy::Form::new();
for (ref checksum, data) in stringified_chunks {
Expand Down

0 comments on commit ace07ee

Please sign in to comment.