perf(memory): optimize C++ string operations to reduce heap fragmentation
- 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>
This commit is contained in:
@@ -60,7 +60,7 @@ BarIpcClient::BarIpcClient(waybar::Bar& bar) : bar_{bar} {
|
||||
});
|
||||
}
|
||||
|
||||
bool BarIpcClient::isModuleEnabled(std::string name) {
|
||||
bool BarIpcClient::isModuleEnabled(const std::string& name) {
|
||||
for (const auto& section : {"modules-left", "modules-center", "modules-right"}) {
|
||||
if (const auto& modules = bar_.config.get(section, {}); modules.isArray()) {
|
||||
for (const auto& module : modules) {
|
||||
|
||||
Reference in New Issue
Block a user