mirror of
https://github.com/rust-lang/rust.git
synced 2026-05-21 17:52:12 +03:00
Auto merge of #16722 - mo8it:allocations, r=Veykril
Avoid some allocations I went on a small `.clone()` hunting tour :D
This commit is contained in:
@@ -37,7 +37,7 @@ pub fn register(&mut self, id: RequestId, data: I) {
|
||||
}
|
||||
|
||||
pub fn cancel(&mut self, id: RequestId) -> Option<Response> {
|
||||
let _data = self.complete(id.clone())?;
|
||||
let _data = self.complete(&id)?;
|
||||
let error = ResponseError {
|
||||
code: ErrorCode::RequestCanceled as i32,
|
||||
message: "canceled by client".to_owned(),
|
||||
@@ -46,8 +46,8 @@ pub fn cancel(&mut self, id: RequestId) -> Option<Response> {
|
||||
Some(Response { id, result: None, error: Some(error) })
|
||||
}
|
||||
|
||||
pub fn complete(&mut self, id: RequestId) -> Option<I> {
|
||||
self.pending.remove(&id)
|
||||
pub fn complete(&mut self, id: &RequestId) -> Option<I> {
|
||||
self.pending.remove(id)
|
||||
}
|
||||
|
||||
pub fn is_completed(&self, id: &RequestId) -> bool {
|
||||
|
||||
Reference in New Issue
Block a user