mirror of
https://github.com/Alexays/Waybar.git
synced 2026-04-01 12:24:00 +00:00
- Replaced pass-by-value std::string parameters with const std::string& or std::string_view to prevent SSO overallocations. - Refactored static mapping functions in UPower to return std::string_view instead of constructing std::string literals, enabling perfect cache locality. - Optimized string concatenation in hot loops (network IPs, inhibitor lists, sway window marks) by using std::string::append() and pre-reserving capacity instead of overloaded operator+ which produces temporary heap instances. These optimizations reduce high-frequency memory churn and overall heap fragmentation within the main rendering loops. Signed-off-by: Austin Horstman <khaneliman12@gmail.com>
29 lines
527 B
C++
29 lines
527 B
C++
#pragma once
|
|
|
|
#include <fmt/format.h>
|
|
#include <sys/statvfs.h>
|
|
|
|
#include <fstream>
|
|
|
|
#include "ALabel.hpp"
|
|
#include "util/format.hpp"
|
|
#include "util/sleeper_thread.hpp"
|
|
|
|
namespace waybar::modules {
|
|
|
|
class Disk : public ALabel {
|
|
public:
|
|
Disk(const std::string&, const Json::Value&);
|
|
virtual ~Disk() = default;
|
|
auto update() -> void override;
|
|
|
|
private:
|
|
util::SleeperThread thread_;
|
|
std::string path_;
|
|
std::string unit_;
|
|
|
|
float calc_specific_divisor(const std::string& divisor);
|
|
};
|
|
|
|
} // namespace waybar::modules
|