Skip to content

Commit

Permalink
remove needless clone
Browse files Browse the repository at this point in the history
  • Loading branch information
niklasad1 committed Jan 15, 2025
1 parent b8d06fd commit 8907996
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions core/src/server/method_response.rs
Original file line number Diff line number Diff line change
Expand Up @@ -297,11 +297,11 @@ impl BatchResponseBuilder {
///
/// Fails if the max limit is exceeded and returns to error response to
/// return early in order to not process method call responses which are thrown away anyway.
pub fn append(&mut self, response: &MethodResponse) -> Result<(), MethodResponse> {
pub fn append(&mut self, response: MethodResponse) -> Result<(), MethodResponse> {
// `,` will occupy one extra byte for each entry
// on the last item the `,` is replaced by `]`.
let len = response.result.len() + self.result.len() + 1;
self.extensions.extend(response.extensions.clone());
self.extensions.extend(response.extensions);

if len > self.max_response_size {
Err(MethodResponse::error(Id::Null, reject_too_big_batch_response(self.max_response_size)))
Expand Down
4 changes: 2 additions & 2 deletions server/src/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1274,7 +1274,7 @@ where
if let Ok(req) = deserialize::from_str_with_extensions(call.get(), extensions.clone()) {
let rp = rpc_service.call(req).await;

if let Err(too_large) = batch_response.append(&rp) {
if let Err(too_large) = batch_response.append(rp) {
return Some(too_large);
}
} else if let Ok(_notif) = serde_json::from_str::<Notif>(call.get()) {
Expand All @@ -1288,7 +1288,7 @@ where
};

if let Err(too_large) =
batch_response.append(&MethodResponse::error(id, ErrorObject::from(ErrorCode::InvalidRequest)))
batch_response.append(MethodResponse::error(id, ErrorObject::from(ErrorCode::InvalidRequest)))
{
return Some(too_large);
}
Expand Down

0 comments on commit 8907996

Please sign in to comment.