Skip to content

Commit

Permalink
Inline cloning the layers into a new Merkle.
Browse files Browse the repository at this point in the history
This was a suggestion from Lee to keep from taking the lock twice.
  • Loading branch information
eljobe committed Jun 28, 2024
1 parent 800f121 commit 21bf88c
Showing 1 changed file with 1 addition and 5 deletions.
6 changes: 1 addition & 5 deletions arbitrator/prover/src/merkle.rs
Original file line number Diff line number Diff line change
Expand Up @@ -199,11 +199,7 @@ fn new_layer(ty: MerkleType, layer: &[Bytes32], empty_hash: &'static Bytes32) ->

impl Clone for Merkle {
fn clone(&self) -> Self {
let leaves = if self.layers.lock().data.is_empty() {
vec![]
} else {
self.layers.lock().data[0].clone()
};
let leaves = self.layers.lock().data.get(0).cloned().unwrap_or_default();
Merkle::new_advanced(self.ty, leaves, self.min_depth)
}
}
Expand Down

0 comments on commit 21bf88c

Please sign in to comment.