about summary refs log tree commit diff
path: root/src/gatherer.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/gatherer.rs')
-rw-r--r--src/gatherer.rs31
1 files changed, 6 insertions, 25 deletions
diff --git a/src/gatherer.rs b/src/gatherer.rs
index c03a0a5..93db7ce 100644
--- a/src/gatherer.rs
+++ b/src/gatherer.rs
@@ -330,36 +330,17 @@ impl Netinfo {
 			tx_bytes: 0,
 		};
 
-		let re = Regex::new(r"[ ]*(\d+)").unwrap();
 		let interface = "eth0:";
 		for line in bread.lines() {
 			let line = line.unwrap();
 			let trim = line.trim();
 
-			let mut captures = if let Some(data) = trim.strip_prefix(interface) {
-				re.captures_iter(data)
-			} else {
-				continue;
-			};
-
-			netinfo.rx_bytes = captures
-				.next()
-				.unwrap()
-				.get(1)
-				.unwrap()
-				.as_str()
-				.parse()
-				.unwrap();
-			netinfo.tx_bytes = captures
-				.skip(7)
-				.next()
-				.unwrap()
-				.get(1)
-				.unwrap()
-				.as_str()
-				.parse()
-				.unwrap();
-			break;
+			if let Some(data) = trim.strip_prefix(interface) {
+				let mut splits = data.split_whitespace();
+				netinfo.rx_bytes = splits.next().unwrap().parse().unwrap();
+				netinfo.tx_bytes = splits.skip(7).next().unwrap().parse().unwrap();
+				break;
+			}
 		}
 
 		netinfo