Skip to content

Commit

Permalink
remove itertools from solana-signer
Browse files Browse the repository at this point in the history
  • Loading branch information
kevinheavey committed Oct 6, 2024
1 parent c7aeb4a commit 4c0cba4
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 5 deletions.
1 change: 0 additions & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion programs/sbf/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion sdk/signer/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ edition = { workspace = true }
[dependencies]
bs58 = { workspace = true, features = ["std"], optional = true }
ed25519-dalek = { workspace = true, optional = true }
itertools = { workspace = true }
rand0-7 = { workspace = true, optional = true }
solana-pubkey = { workspace = true }
solana-signature = { workspace = true }
Expand Down
13 changes: 11 additions & 2 deletions sdk/signer/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
//! Abstractions and implementations for transaction signers.
use {
core::fmt,
itertools::Itertools,
solana_pubkey::Pubkey,
solana_signature::Signature,
solana_transaction_error::TransactionError,
Expand Down Expand Up @@ -164,7 +163,17 @@ impl std::fmt::Debug for dyn Signer {

/// Removes duplicate signers while preserving order. O(n²)
pub fn unique_signers(signers: Vec<&dyn Signer>) -> Vec<&dyn Signer> {
signers.into_iter().unique_by(|s| s.pubkey()).collect()
let capacity = signers.len();
let mut out = Vec::with_capacity(capacity);
let mut seen = std::collections::HashSet::with_capacity(capacity);
for signer in signers {
let pubkey = signer.pubkey();
if !seen.contains(&pubkey) {
seen.insert(pubkey);
out.push(signer);
}
}
out
}

/// The `EncodableKey` trait defines the interface by which cryptographic keys/keypairs are read,
Expand Down

0 comments on commit 4c0cba4

Please sign in to comment.