Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 8966132

Browse files
committedDec 5, 2024·
clone as little as possible into closures
1 parent bdc9e23 commit 8966132

File tree

2 files changed

+8
-14
lines changed

2 files changed

+8
-14
lines changed
 

‎src/net_protocol.rs

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -393,24 +393,20 @@ impl<S: crate::store::Store> Blobs<S> {
393393

394394
impl<S: crate::store::Store> ProtocolHandler for Blobs<S> {
395395
fn accept(&self, conn: Connecting) -> BoxedFuture<Result<()>> {
396-
let this = self.clone();
396+
let db = self.store.clone();
397+
let events = self.events.clone();
398+
let rt = self.rt.clone();
397399

398400
Box::pin(async move {
399-
crate::provider::handle_connection(
400-
conn.await?,
401-
this.store.clone(),
402-
this.events.clone(),
403-
this.rt.clone(),
404-
)
405-
.await;
401+
crate::provider::handle_connection(conn.await?, db, events, rt).await;
406402
Ok(())
407403
})
408404
}
409405

410406
fn shutdown(&self) -> BoxedFuture<()> {
411-
let this = self.clone();
407+
let store = self.store.clone();
412408
Box::pin(async move {
413-
this.store.shutdown().await;
409+
store.shutdown().await;
414410
})
415411
}
416412
}

‎src/rpc.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -80,11 +80,9 @@ impl<D: crate::store::Store> Blobs<D> {
8080
where
8181
C: ChannelTypes<RpcService>,
8282
{
83-
use Request::*;
84-
let handler = self;
8583
match msg {
86-
Blobs(msg) => handler.handle_blobs_request(msg, chan).await,
87-
Tags(msg) => handler.handle_tags_request(msg, chan).await,
84+
Request::Blobs(msg) => self.handle_blobs_request(msg, chan).await,
85+
Request::Tags(msg) => self.handle_tags_request(msg, chan).await,
8886
}
8987
}
9088

0 commit comments

Comments
 (0)
Please sign in to comment.