Skip to content

Commit

Permalink
cluster: send_use_keyspace(): avoid Vec allocation
Browse files Browse the repository at this point in the history
As `join_all()` accepts any `IntoIterator`, it accepts iterators in
particular. Allocating a `Vec` is unnecessary.
  • Loading branch information
wprzytula committed Jul 31, 2023
1 parent ec4c8f8 commit a27b28f
Showing 1 changed file with 1 addition and 7 deletions.
8 changes: 1 addition & 7 deletions scylla/src/transport/cluster.rs
Expand Up @@ -584,13 +584,7 @@ impl ClusterWorker {
cluster_data: Arc<ClusterData>,
keyspace_name: &VerifiedKeyspaceName,
) -> Result<(), QueryError> {
let mut use_keyspace_futures = Vec::new();

for node in cluster_data.known_peers.values() {
let fut = node.use_keyspace(keyspace_name.clone());
use_keyspace_futures.push(fut);
}

let use_keyspace_futures = cluster_data.known_peers.values().map(|node| node.use_keyspace(keyspace_name.clone()));
let use_keyspace_results: Vec<Result<(), QueryError>> =
join_all(use_keyspace_futures).await;

Expand Down

0 comments on commit a27b28f

Please sign in to comment.