Skip to content

Commit

Permalink
refiller: remove needless has_connections() method
Browse files Browse the repository at this point in the history
This is just a negation of `is_empty()` method.

For reference:
```
    fn is_empty(&self) -> bool {
        self.conns.iter().all(|conns| conns.is_empty())
    }
```
  • Loading branch information
muzarski committed Oct 25, 2024
1 parent 113f500 commit 81d9576
Showing 1 changed file with 2 additions and 6 deletions.
8 changes: 2 additions & 6 deletions scylla/src/transport/connection_pool.rs
Original file line number Diff line number Diff line change
Expand Up @@ -988,7 +988,7 @@ impl PoolRefiller {
// `last_error` must not be `None` if there is a possibility of the pool
// being empty.
fn update_shared_conns(&mut self, last_error: Option<ConnectionError>) {
let new_conns = if !self.has_connections() {
let new_conns = if self.is_empty() {
Arc::new(MaybePoolConnections::Broken(last_error.unwrap()))
} else {
let new_conns = if let Some(sharder) = self.sharder.as_ref() {
Expand Down Expand Up @@ -1046,7 +1046,7 @@ impl PoolRefiller {
self.conns[shard_id].len(),
self.active_connection_count(),
);
if !self.has_connections() {
if self.is_empty() {
let _ = self.pool_empty_notifier.send(());
}
self.update_shared_conns(Some(last_error));
Expand Down Expand Up @@ -1152,10 +1152,6 @@ impl PoolRefiller {
);
}

fn has_connections(&self) -> bool {
self.conns.iter().any(|v| !v.is_empty())
}

fn active_connection_count(&self) -> usize {
self.conns.iter().map(Vec::len).sum::<usize>()
}
Expand Down

0 comments on commit 81d9576

Please sign in to comment.