From 80dda3319833f571d04b029ec65af57b0da055c9 Mon Sep 17 00:00:00 2001 From: Drath Date: Sun, 2 Nov 2025 12:53:34 +0100 Subject: [PATCH] use the new macro --- src/sys.cpp | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/sys.cpp b/src/sys.cpp index d1b6650..fea863d 100644 --- a/src/sys.cpp +++ b/src/sys.cpp @@ -1,6 +1,7 @@ #include #include +#include #include #include #include @@ -37,12 +38,13 @@ void sys::getNetwork(Network* net, std::string device) { uint64_t tx = 0; }; + static char buf[24]; static _net prev; _net current; current.ts = std::chrono::steady_clock::now(); - current.rx = std::stoull(readFile("/sys/class/net/" + device + "/statistics/rx_bytes", 32)); - current.tx = std::stoull(readFile("/sys/class/net/" + device + "/statistics/tx_bytes", 32)); + fastReadNum("/sys/class/net/" + device + "/statistics/rx_bytes", current.rx); + fastReadNum("/sys/class/net/" + device + "/statistics/tx_bytes", current.tx); float ts_diff = std::chrono::duration_cast(current.ts - prev.ts).count() / 1000000.0f; net->download = (current.rx - prev.rx) / ts_diff; net->upload = (current.tx - prev.tx) / ts_diff; @@ -54,7 +56,8 @@ void sys::detectHwmon(sysSensors* s, std::string platform) { } void sys::updateSensors(sysSensors* s) { - s->fan_speed[0] = std::stol(readFile(s->hwmon + "/fan2_input", 4)); - s->fan_speed[1] = std::stol(readFile(s->hwmon + "/fan7_input", 4)); - s->t_sensor = std::stol(readFile(s->hwmon + "/temp5_input", 2)); + static char buf[8]; + fastReadNum(s->hwmon + "/fan2_input", s->fan_speed[0]); + fastReadNum(s->hwmon + "/fan7_input", s->fan_speed[1]); + fastReadNum(s->hwmon + "/temp5_input", s->t_sensor) / 1000; }