diff options
author | Clement Tsang <34804052+ClementTsang@users.noreply.github.com> | 2020-11-22 13:44:40 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-11-22 16:44:40 -0500 |
commit | 6aa0dd64a663029a0c77159c4229e00a10967b86 (patch) | |
tree | f2c4d2508a8dd42a6a5b877b7887f358419adfff /src/app | |
parent | 5abb1ce1a3cd847bfd876d5b7f940db25e7e6aca (diff) |
other: Switch to once_cell (#324)
Switch from lazy_static to once_cell.
Diffstat (limited to 'src/app')
-rw-r--r-- | src/app/data_farmer.rs | 7 | ||||
-rw-r--r-- | src/app/data_harvester/processes.rs | 2 |
2 files changed, 4 insertions, 5 deletions
diff --git a/src/app/data_farmer.rs b/src/app/data_farmer.rs index 5238c9cc..6120afa5 100644 --- a/src/app/data_farmer.rs +++ b/src/app/data_farmer.rs @@ -1,4 +1,3 @@ -use lazy_static::lazy_static; /// In charge of cleaning, processing, and managing data. I couldn't think of /// a better name for the file. Since I called data collection "harvesting", /// then this is the farmer I guess. @@ -13,6 +12,8 @@ use lazy_static::lazy_static; /// call the purging function. Failure to do so *will* result in a growing /// memory usage and higher CPU usage - you will be trying to process more and /// more points as this is used! +use once_cell::sync::Lazy; + use std::{time::Instant, vec::Vec}; use crate::{ @@ -245,9 +246,7 @@ impl DataCollection { if let Some(trim) = device.name.split('/').last() { let io_device = if cfg!(target_os = "macos") { // Must trim one level further! - lazy_static! { - static ref DISK_REGEX: Regex = Regex::new(r"disk\d+").unwrap(); - } + static DISK_REGEX: Lazy<Regex> = Lazy::new(|| Regex::new(r"disk\d+").unwrap()); if let Some(disk_trim) = DISK_REGEX.find(trim) { io.get(disk_trim.as_str()) } else { diff --git a/src/app/data_harvester/processes.rs b/src/app/data_harvester/processes.rs index ce104082..a182db23 100644 --- a/src/app/data_harvester/processes.rs +++ b/src/app/data_harvester/processes.rs @@ -11,7 +11,7 @@ use std::collections::{hash_map::RandomState, HashMap}; #[cfg(not(target_os = "linux"))] use sysinfo::{ProcessExt, ProcessorExt, System, SystemExt}; -/// Maximum character length of a /proc/<PID>/stat process name. +/// Maximum character length of a /proc/<PID>/stat process name that we'll accept. #[cfg(target_os = "linux")] const MAX_STAT_NAME_LEN: usize = 15; |