Skip to content

Commit

Permalink
Exit early if iterator is empty
Browse files Browse the repository at this point in the history
  • Loading branch information
gligneul committed Feb 4, 2025
1 parent f28e5e5 commit 8e86745
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion stylus-sdk/src/storage/bytes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,11 @@ impl Erase for StorageBytes {

impl Extend<u8> for StorageBytes {
fn extend<T: IntoIterator<Item = u8>>(&mut self, iter: T) {
let mut iter = iter.into_iter();
let mut iter = iter.into_iter().peekable();
if iter.peek().is_none() {
return;
}

let mut root = BytesRoot::new_mut(self);
let mut len = root.len();

Expand Down

0 comments on commit 8e86745

Please sign in to comment.