Skip to content

Commit 9db16f6

Browse files
authored
Merge pull request #5148 from jbencin/chore/remove-slice_partialeq
chore: Remove unnecessary function `slice_partialeq()`
2 parents 457afc0 + 3fb981f commit 9db16f6

File tree

3 files changed

+9
-26
lines changed

3 files changed

+9
-26
lines changed

stacks-common/src/util/mod.rs

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -85,19 +85,6 @@ impl error::Error for HexError {
8585
}
8686
}
8787

88-
/// PartialEq helper method for slices of arbitrary length.
89-
pub fn slice_partialeq<T: PartialEq>(s1: &[T], s2: &[T]) -> bool {
90-
if s1.len() != s2.len() {
91-
return false;
92-
}
93-
for i in 0..s1.len() {
94-
if s1[i] != s2[i] {
95-
return false;
96-
}
97-
}
98-
true
99-
}
100-
10188
pub mod db_common {
10289
use std::{thread, time};
10390

stackslib/src/chainstate/stacks/index/node.rs

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ use stacks_common::types::chainstate::{
2727
BlockHeaderHash, TrieHash, BLOCK_HEADER_HASH_ENCODED_SIZE, TRIEHASH_ENCODED_SIZE,
2828
};
2929
use stacks_common::util::hash::to_hex;
30-
use stacks_common::util::slice_partialeq;
3130

3231
use crate::chainstate::stacks::index::bits::{
3332
get_path_byte_len, get_ptrs_byte_len, path_from_bytes, ptrs_from_bytes, write_path_to_bytes,
@@ -597,7 +596,7 @@ impl<T: MarfTrieId> TrieCursor<T> {
597596

598597
impl PartialEq for TrieLeaf {
599598
fn eq(&self, other: &TrieLeaf) -> bool {
600-
self.path == other.path && slice_partialeq(self.data.as_bytes(), other.data.as_bytes())
599+
self.path == other.path && self.data.as_bytes() == other.data.as_bytes()
601600
}
602601
}
603602

@@ -730,9 +729,7 @@ impl fmt::Debug for TrieNode48 {
730729

731730
impl PartialEq for TrieNode48 {
732731
fn eq(&self, other: &TrieNode48) -> bool {
733-
self.path == other.path
734-
&& slice_partialeq(&self.ptrs, &other.ptrs)
735-
&& slice_partialeq(&self.indexes, &other.indexes)
732+
self.path == other.path && self.ptrs == other.ptrs && self.indexes == other.indexes
736733
}
737734
}
738735

@@ -755,8 +752,8 @@ impl TrieNode48 {
755752
}
756753
TrieNode48 {
757754
path: node16.path.clone(),
758-
indexes: indexes,
759-
ptrs: ptrs,
755+
indexes,
756+
ptrs,
760757
}
761758
}
762759
}
@@ -781,7 +778,7 @@ impl fmt::Debug for TrieNode256 {
781778

782779
impl PartialEq for TrieNode256 {
783780
fn eq(&self, other: &TrieNode256) -> bool {
784-
self.path == other.path && slice_partialeq(&self.ptrs, &other.ptrs)
781+
self.path == other.path && self.ptrs == other.ptrs
785782
}
786783
}
787784

stackslib/src/chainstate/stacks/index/proofs.rs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ use stacks_common::types::chainstate::{
2828
BlockHeaderHash, TrieHash, BLOCK_HEADER_HASH_ENCODED_SIZE, TRIEHASH_ENCODED_SIZE,
2929
};
3030
use stacks_common::util::hash::to_hex;
31-
use stacks_common::util::slice_partialeq;
3231

3332
use crate::chainstate::stacks::index::bits::{
3433
get_leaf_hash, get_node_hash, read_root_hash, write_path_to_bytes,
@@ -118,19 +117,19 @@ impl<T: ClarityMarfTrieId> PartialEq for TrieMerkleProofType<T> {
118117
(
119118
TrieMerkleProofType::Node4((ref chr, ref node, ref hashes)),
120119
TrieMerkleProofType::Node4((ref other_chr, ref other_node, ref other_hashes)),
121-
) => chr == other_chr && node == other_node && slice_partialeq(hashes, other_hashes),
120+
) => chr == other_chr && node == other_node && hashes == other_hashes,
122121
(
123122
TrieMerkleProofType::Node16((ref chr, ref node, ref hashes)),
124123
TrieMerkleProofType::Node16((ref other_chr, ref other_node, ref other_hashes)),
125-
) => chr == other_chr && node == other_node && slice_partialeq(hashes, other_hashes),
124+
) => chr == other_chr && node == other_node && hashes == other_hashes,
126125
(
127126
TrieMerkleProofType::Node48((ref chr, ref node, ref hashes)),
128127
TrieMerkleProofType::Node48((ref other_chr, ref other_node, ref other_hashes)),
129-
) => chr == other_chr && node == other_node && slice_partialeq(hashes, other_hashes),
128+
) => chr == other_chr && node == other_node && hashes == other_hashes,
130129
(
131130
TrieMerkleProofType::Node256((ref chr, ref node, ref hashes)),
132131
TrieMerkleProofType::Node256((ref other_chr, ref other_node, ref other_hashes)),
133-
) => chr == other_chr && node == other_node && slice_partialeq(hashes, other_hashes),
132+
) => chr == other_chr && node == other_node && hashes == other_hashes,
134133
(
135134
TrieMerkleProofType::Leaf((ref chr, ref node)),
136135
TrieMerkleProofType::Leaf((ref other_chr, ref other_node)),

0 commit comments

Comments
 (0)