Skip to content

Commit

Permalink
chore: Remove redundant temporary variable (#2095)
Browse files Browse the repository at this point in the history
  • Loading branch information
tottoto authored Dec 13, 2024
1 parent 7a38316 commit 3581559
Showing 1 changed file with 8 additions and 12 deletions.
20 changes: 8 additions & 12 deletions tonic/src/server/grpc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -183,40 +183,36 @@ where

#[doc(hidden)]
pub fn apply_compression_config(
self,
mut self,
accept_encodings: EnabledCompressionEncodings,
send_encodings: EnabledCompressionEncodings,
) -> Self {
let mut this = self;

for &encoding in CompressionEncoding::ENCODINGS {
if accept_encodings.is_enabled(encoding) {
this = this.accept_compressed(encoding);
self = self.accept_compressed(encoding);
}
if send_encodings.is_enabled(encoding) {
this = this.send_compressed(encoding);
self = self.send_compressed(encoding);
}
}

this
self
}

#[doc(hidden)]
pub fn apply_max_message_size_config(
self,
mut self,
max_decoding_message_size: Option<usize>,
max_encoding_message_size: Option<usize>,
) -> Self {
let mut this = self;

if let Some(limit) = max_decoding_message_size {
this = this.max_decoding_message_size(limit);
self = self.max_decoding_message_size(limit);
}
if let Some(limit) = max_encoding_message_size {
this = this.max_encoding_message_size(limit);
self = self.max_encoding_message_size(limit);
}

this
self
}

/// Handle a single unary gRPC request.
Expand Down

0 comments on commit 3581559

Please sign in to comment.