Skip to content

Commit

Permalink
Wrap inbox prefix in an Arc
Browse files Browse the repository at this point in the history
The goal of the `Client` struct was to be a clonable handle. However,
the struct contained a bare string that was cloned each time. In apps
that clone the client regularly, this lead to quite a few allocations.

This is a non-breaking change purely internal to the client

Signed-off-by: Taylor Thomas <taylor@cosmonic.com>
  • Loading branch information
thomastaylor312 authored Mar 26, 2024
1 parent 182efc2 commit a49c239
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions async-nats/src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ pub struct Client {
pub(crate) sender: mpsc::Sender<Command>,
next_subscription_id: Arc<AtomicU64>,
subscription_capacity: usize,
inbox_prefix: String,
inbox_prefix: Arc<str>,
request_timeout: Option<Duration>,
max_payload: Arc<AtomicUsize>,
}
Expand All @@ -90,7 +90,7 @@ impl Client {
sender,
next_subscription_id: Arc::new(AtomicU64::new(1)),
subscription_capacity: capacity,
inbox_prefix,
inbox_prefix: inbox_prefix.into(),
request_timeout,
max_payload,
}
Expand Down

0 comments on commit a49c239

Please sign in to comment.