Skip to content
This repository was archived by the owner on Mar 11, 2025. It is now read-only.

Commit 7218128

Browse files
committed
cargo clippy over new code
1 parent 12c625e commit 7218128

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

account-compression/programs/account-compression/src/canopy.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ pub fn set_canopy_leaf_nodes(
156156
canopy[start_canopy_idx + i] = *node;
157157
}
158158
let mut start_canopy_node = start_canopy_node;
159-
let mut end_canopy_node = start_canopy_node + nodes.len() - 1 as usize;
159+
let mut end_canopy_node = start_canopy_node + nodes.len() - 1;
160160
let mut empty_node_cache = Box::new([EMPTY; MAX_SUPPORTED_DEPTH]);
161161
let leaf_node_level = max_depth - path_len;
162162
// traverse up the tree and update the parent nodes in the modified subtree
@@ -167,16 +167,16 @@ pub fn set_canopy_leaf_nodes(
167167
let left_child = get_value_for_node::<MAX_SUPPORTED_DEPTH>(
168168
node << 1,
169169
level - 1,
170-
&canopy,
170+
canopy,
171171
&mut empty_node_cache,
172172
);
173173
let right_child = get_value_for_node::<MAX_SUPPORTED_DEPTH>(
174174
(node << 1) + 1,
175175
level - 1,
176-
&canopy,
176+
canopy,
177177
&mut empty_node_cache,
178178
);
179-
canopy[node - 2 as usize].copy_from_slice(hashv(&[&left_child, &right_child]).as_ref());
179+
canopy[node - 2].copy_from_slice(hashv(&[&left_child, &right_child]).as_ref());
180180
}
181181
}
182182
Ok(())
@@ -186,7 +186,7 @@ pub fn set_canopy_leaf_nodes(
186186
pub fn check_canopy_root(canopy_bytes: &[u8], expected_root: &Node) -> Result<()> {
187187
check_canopy_bytes(canopy_bytes)?;
188188
let canopy = cast_slice::<u8, Node>(canopy_bytes);
189-
if canopy.len() < 1 {
189+
if canopy.is_empty() {
190190
return Ok(()); // Canopy is empty
191191
}
192192
let actual_root = hashv(&[&canopy[0], &canopy[1]]).to_bytes();
@@ -219,7 +219,7 @@ pub fn check_canopy_no_nodes_to_right_of_index(
219219

220220
let mut node_idx = ((1 << max_depth) + index) >> (max_depth - path_len);
221221
// no need to check the node_idx as it's the leaf continaing the index underneath it
222-
while node_idx & node_idx + 1 != 0 {
222+
while node_idx & (node_idx + 1) != 0 {
223223
// check the next node to the right
224224
node_idx += 1;
225225
// find the top-most node that has the node as its left-most child

account-compression/programs/account-compression/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -276,7 +276,7 @@ pub mod spl_account_compression {
276276
let (header_bytes, rest) =
277277
merkle_tree_bytes.split_at_mut(CONCURRENT_MERKLE_TREE_HEADER_SIZE_V1);
278278
// the header should already be initialized with prepare_tree
279-
let header = ConcurrentMerkleTreeHeader::try_from_slice(&header_bytes)?;
279+
let header = ConcurrentMerkleTreeHeader::try_from_slice(header_bytes)?;
280280
header.assert_valid_authority(&ctx.accounts.authority.key())?;
281281
let merkle_tree_size = merkle_tree_get_size(&header)?;
282282
let (tree_bytes, canopy_bytes) = rest.split_at_mut(merkle_tree_size);

0 commit comments

Comments
 (0)