mirror of
				https://github.com/rad4day/Waybar.git
				synced 2025-10-31 07:52:42 +01:00 
			
		
		
		
	fix(pulseaudio): Avoid allocation of string vector on every call of getPortIcon()
This commit is contained in:
		| @@ -1,4 +1,5 @@ | ||||
| #include "modules/pulseaudio.hpp" | ||||
| #include <array> | ||||
|  | ||||
| waybar::modules::Pulseaudio::Pulseaudio(const std::string& id, const Json::Value &config) | ||||
|     : ALabel(config, "{volume}%"), | ||||
| @@ -174,19 +175,20 @@ void waybar::modules::Pulseaudio::serverInfoCb(pa_context *context, | ||||
|     sinkInfoCb, data); | ||||
| } | ||||
|  | ||||
| static const std::array<std::string, 9> ports = { | ||||
|   "headphones", | ||||
|   "speaker", | ||||
|   "hdmi", | ||||
|   "headset", | ||||
|   "handsfree", | ||||
|   "portable", | ||||
|   "car", | ||||
|   "hifi", | ||||
|   "phone", | ||||
| }; | ||||
|  | ||||
| const std::string waybar::modules::Pulseaudio::getPortIcon() const | ||||
| { | ||||
|   std::vector<std::string> ports = { | ||||
|     "headphones", | ||||
|     "speaker", | ||||
|     "hdmi", | ||||
|     "headset", | ||||
|     "handsfree", | ||||
|     "portable", | ||||
|     "car", | ||||
|     "hifi", | ||||
|     "phone", | ||||
|   }; | ||||
|   std::string nameLC = port_name_; | ||||
|   std::transform(nameLC.begin(), nameLC.end(), nameLC.begin(), ::tolower); | ||||
|   for (auto const& port : ports) { | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 Aleksei Bavshin
					Aleksei Bavshin