From e1f8c001dd4d792b059b38f68bd52d1343ae7666 Mon Sep 17 00:00:00 2001 From: Michael Carlberg Date: Tue, 21 Jun 2016 03:59:43 +0200 Subject: [PATCH] refactor: Pass by value --- include/bar.hpp | 2 +- include/drawtypes/animation.hpp | 2 +- include/drawtypes/bar.hpp | 4 ++-- include/drawtypes/icon.hpp | 14 +++++++------- include/drawtypes/label.hpp | 10 +++++----- include/drawtypes/ramp.hpp | 2 +- include/eventloop.hpp | 2 +- include/interfaces/alsa.hpp | 8 ++++---- include/interfaces/mpd.hpp | 10 +++++----- include/interfaces/net.hpp | 10 +++++----- include/lemonbuddy.hpp | 2 +- include/modules/backlight.hpp | 4 ++-- include/modules/base.hpp | 15 +++++++-------- include/modules/battery.hpp | 4 ++-- include/modules/bspwm.hpp | 6 +++--- include/modules/counter.hpp | 4 ++-- include/modules/cpu.hpp | 4 ++-- include/modules/date.hpp | 6 +++--- include/modules/i3.hpp | 6 +++--- include/modules/memory.hpp | 4 ++-- include/modules/menu.hpp | 6 +++--- include/modules/mpd.hpp | 6 +++--- include/modules/network.hpp | 4 ++-- include/modules/script.hpp | 4 ++-- include/modules/text.hpp | 2 +- include/modules/volume.hpp | 7 +++---- include/registry.hpp | 6 +++--- include/services/builder.hpp | 22 +++++++++++----------- include/services/command.hpp | 4 ++-- include/services/inotify.hpp | 4 ++-- include/services/store.hpp | 2 +- include/utils/cli.hpp | 20 ++++++++++---------- include/utils/config.hpp | 18 +++++++++--------- include/utils/io.hpp | 20 ++++++++++---------- include/utils/proc.hpp | 2 +- include/utils/string.hpp | 30 +++++++++++++++--------------- include/utils/xlib.hpp | 2 +- src/drawtypes/animation.cpp | 2 +- src/drawtypes/bar.cpp | 4 ++-- src/drawtypes/icon.cpp | 10 +++++----- src/drawtypes/label.cpp | 6 +++--- src/drawtypes/ramp.cpp | 2 +- src/eventloop.cpp | 2 +- src/interfaces/alsa.cpp | 2 +- src/interfaces/net.cpp | 8 ++++---- src/lemonbuddy.cpp | 5 +++-- src/modules/backlight.cpp | 4 ++-- src/modules/base.cpp | 5 +++-- src/modules/battery.cpp | 4 ++-- src/modules/bspwm.cpp | 6 +++--- src/modules/counter.cpp | 4 ++-- src/modules/cpu.cpp | 4 ++-- src/modules/date.cpp | 6 +++--- src/modules/i3.cpp | 6 +++--- src/modules/memory.cpp | 6 +++--- src/modules/menu.cpp | 6 +++--- src/modules/mpd.cpp | 6 +++--- src/modules/network.cpp | 4 ++-- src/modules/script.cpp | 4 ++-- src/modules/text.cpp | 2 +- src/modules/volume.cpp | 6 +++--- src/registry.cpp | 6 +++--- src/services/builder.cpp | 22 +++++++++++----------- src/services/command.cpp | 4 ++-- src/services/inotify.cpp | 2 +- src/services/store.cpp | 2 +- src/utils/cli.cpp | 18 +++++++++--------- src/utils/config.cpp | 8 ++++---- src/utils/io.cpp | 18 +++++++++--------- src/utils/proc.cpp | 2 +- src/utils/string.cpp | 30 +++++++++++++++--------------- src/utils/xlib.cpp | 2 +- 72 files changed, 253 insertions(+), 253 deletions(-) diff --git a/include/bar.hpp b/include/bar.hpp index 96f92608..bdd9124a 100644 --- a/include/bar.hpp +++ b/include/bar.hpp @@ -20,7 +20,7 @@ struct Font std::string id; int offset; - Font(const std::string& id, int offset) + Font(std::string id, int offset) : id(id), offset(offset){} }; diff --git a/include/drawtypes/animation.hpp b/include/drawtypes/animation.hpp index 1ddffff2..a003fdb2 100644 --- a/include/drawtypes/animation.hpp +++ b/include/drawtypes/animation.hpp @@ -34,5 +34,5 @@ namespace drawtypes } }; - std::unique_ptr get_config_animation(const std::string& config_path, const std::string& animation_name = "animation", bool required = true); + std::unique_ptr get_config_animation(std::string config_path, std::string animation_name = "animation", bool required = true); } diff --git a/include/drawtypes/bar.hpp b/include/drawtypes/bar.hpp index 1a9379aa..220401f3 100644 --- a/include/drawtypes/bar.hpp +++ b/include/drawtypes/bar.hpp @@ -24,7 +24,7 @@ namespace drawtypes std::unique_ptr indicator; public: - Bar(int width, const std::string& fmt, bool lazy_builder_closing = true); + Bar(int width, std::string fmt, bool lazy_builder_closing = true); Bar(int width, bool lazy_builder_closing = true) : Bar(width, "", lazy_builder_closing){} @@ -38,5 +38,5 @@ namespace drawtypes std::string get_output(float percentage, bool floor_percentage = false); }; - std::unique_ptr get_config_bar(const std::string& config_path, const std::string& bar_name = "bar", bool lazy_builder_closing = true); + std::unique_ptr get_config_bar(std::string config_path, std::string bar_name = "bar", bool lazy_builder_closing = true); } diff --git a/include/drawtypes/icon.hpp b/include/drawtypes/icon.hpp index 85304cbc..412986de 100644 --- a/include/drawtypes/icon.hpp +++ b/include/drawtypes/icon.hpp @@ -11,9 +11,9 @@ namespace drawtypes { struct Icon : public Label { - Icon(const std::string& icon, int font = 0) + Icon(std::string icon, int font = 0) : Label(icon, font){} - Icon(const std::string& icon, const std::string& fg, const std::string& bg = "", const std::string& ul = "", const std::string& ol = "", int font = 0, int padding = 0, int margin = 0) + Icon(std::string icon, std::string fg, std::string bg = "", std::string ul = "", std::string ol = "", int font = 0, int padding = 0, int margin = 0) : Label(icon, fg, bg, ul, ol, font, padding, margin){} std::unique_ptr clone(); @@ -24,15 +24,15 @@ namespace drawtypes std::map> icons; public: - void add(const std::string& id, std::unique_ptr &&icon); - std::unique_ptr &get(const std::string& id, const std::string& fallback_id = ""); - bool has(const std::string& id); + void add(std::string id, std::unique_ptr &&icon); + std::unique_ptr &get(std::string id, std::string fallback_id = ""); + bool has(std::string id); operator bool() { return this->icons.size() > 0; } }; - std::unique_ptr get_config_icon(const std::string& module_name, const std::string& icon_name = "icon", bool required = true, const std::string& def = ""); - std::unique_ptr get_optional_config_icon(const std::string& module_name, const std::string& icon_name = "icon", const std::string& def = ""); + std::unique_ptr get_config_icon(std::string module_name, std::string icon_name = "icon", bool required = true, std::string def = ""); + std::unique_ptr get_optional_config_icon(std::string module_name, std::string icon_name = "icon", std::string def = ""); } diff --git a/include/drawtypes/label.hpp b/include/drawtypes/label.hpp index 52cd8b7c..9825e43a 100644 --- a/include/drawtypes/label.hpp +++ b/include/drawtypes/label.hpp @@ -10,9 +10,9 @@ namespace drawtypes std::string text, fg, bg, ul, ol; int font = 0, padding = 0, margin = 0; - Label(const std::string& text, int font) + Label(std::string text, int font) : text(text), font(font){} - Label(const std::string& text, const std::string& fg = "", const std::string& bg = "", const std::string& ul = "", const std::string& ol = "", int font = 0, int padding = 0, int margin = 0) + Label(std::string text, std::string fg = "", std::string bg = "", std::string ul = "", std::string ol = "", int font = 0, int padding = 0, int margin = 0) : text(text), fg(fg), bg(bg), ul(ul), ol(ol), font(font), padding(padding), margin(margin){} operator bool() { @@ -21,10 +21,10 @@ namespace drawtypes std::unique_ptr