Reduce temp allocations in network metrics (#1895)

## Issue Addressed

Using `heaptrack` I could see that ~75% of Lighthouse temporary allocations are caused by temporary string allocations here.

## Proposed Changes

Reduces temporary `String` allocations when updating metrics in the `network` crate. The solution isn't perfect since we rebuild our caches with each call, but it's a significant improvement.

## Additional Info

NA
This commit is contained in:
Paul Hauner
2020-11-13 04:19:38 +00:00
parent c7ac967d5a
commit 8772c02fa0
2 changed files with 39 additions and 13 deletions

View File

@@ -75,3 +75,9 @@ impl Into<u64> for SubnetId {
self.0
}
}
impl Into<u64> for &SubnetId {
fn into(self) -> u64 {
self.0
}
}