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 Aug 3, 2023
1 parent 5aff154 commit 73373d2
Showing 1 changed file with 4 additions and 7 deletions.
11 changes: 4 additions & 7 deletions scylla/src/transport/cluster.rs
Expand Up @@ -588,13 +588,10 @@ 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 73373d2

Please sign in to comment.