Skip to content

Commit

Permalink
Minor refactor of functionally same code (#607)
Browse files Browse the repository at this point in the history
* Use truncate over resize_with(1, || "".to_string()) reduce added function allocations/calls
* Reformat if/let logic
* Fix spelling error
  • Loading branch information
adam-singer committed Jan 16, 2024
1 parent 95afd36 commit 51715bd
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 5 deletions.
2 changes: 1 addition & 1 deletion nativelink-service/src/bytestream_server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,7 @@ impl ByteStreamServer {
// Trim the error code. Not Found is quite common and we don't want to send a large
// error (debug) message for something that is common. We resize to just the last
// message as it will be the most relevant.
e.messages.resize_with(1, || "".to_string());
e.messages.truncate(1);
}
info!("\x1b[0;31mBytestream Read Chunk Resp\x1b[0m: Error {:?}", e);
return Some((Err(e.into()), None))
Expand Down
4 changes: 1 addition & 3 deletions nativelink-store/src/grpc_store.rs
Original file line number Diff line number Diff line change
Expand Up @@ -646,9 +646,7 @@ impl Store for GrpcStore {
.message()
.await
.err_tip(|| "While fetching message in GrpcStore::get_part()")?;
let message = if let Some(message) = maybe_message {
message
} else {
let Some(message) = maybe_message else {
writer
.send_eof()
.await
Expand Down
2 changes: 1 addition & 1 deletion nativelink-util/src/evicting_map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -411,7 +411,7 @@ impl<T: LenEntry + Debug, I: InstantWrapper> MetricsComponent for EvictingMap<T,
&state.sum_store_size,
"Total size of all items in the store",
);
c.publish("items_in_store_total", &state.lru.len(), "Mumber of items in the store");
c.publish("items_in_store_total", &state.lru.len(), "Number of items in the store");
c.publish(
"oldest_item_timestamp",
&state
Expand Down

0 comments on commit 51715bd

Please sign in to comment.