Simplify MemoryStats fetching

This commit is contained in:
Clément Renault 2024-02-07 10:09:39 +01:00 committed by Louis Dureuil
parent 4de2db6786
commit f3c34d5b8c
No known key found for this signature in database
2 changed files with 6 additions and 7 deletions

View File

@ -121,6 +121,11 @@ impl MemoryStats {
}
}
#[cfg(not(any(target_os = "linux", target_os = "macos")))]
pub fn fetch() -> Option<Self> {
None
}
pub fn checked_sub(self, other: Self) -> Option<Self> {
Some(Self { resident: self.resident.checked_sub(other.resident)? })
}

View File

@ -96,14 +96,8 @@ impl TraceLayer {
self.start_time.elapsed()
}
#[cfg(any(target_os = "linux", target_os = "macos"))]
fn memory_stats(&self) -> Option<MemoryStats> {
Some(MemoryStats::fetch().unwrap())
}
#[cfg(not(any(target_os = "linux", target_os = "macos")))]
fn memory_stats(&self) -> Option<MemoryStats> {
None
MemoryStats::fetch()
}
fn send(&self, entry: Entry) {