diff --git a/src/env.h b/src/env.h index 552480069..dd9c69892 100644 --- a/src/env.h +++ b/src/env.h @@ -74,28 +74,24 @@ class env_var_t { wcstring_list_t vals; // list of values assigned to the var public: - bool exportv; // whether the variable should be exported + bool exportv = false; // whether the variable should be exported // Constructors. - env_var_t(const env_var_t &v) : name(v.name), vals(v.vals), exportv(v.exportv) {} - env_var_t(const wcstring &our_name, const wcstring_list_t &l) - : name(our_name), vals(l), exportv(false) {} - env_var_t(const wcstring &our_name, const wcstring &s) - : name(our_name), - vals({ - s, - }), - exportv(false) {} - env_var_t(const wcstring &our_name, const wchar_t *s) - : name(our_name), - vals({ - wcstring(s), - }), - exportv(false) {} - env_var_t() : name(), vals(), exportv(false) {} + env_var_t(const env_var_t &) = default; + env_var_t(env_var_t &&) = default; + env_var_t(wcstring name, wcstring_list_t vals) : name(std::move(name)), vals(std::move(vals)) {} - bool empty(void) const { return vals.empty() || (vals.size() == 1 && vals[0].empty()); }; - bool read_only(void) const; + env_var_t(wcstring name, wcstring val) + : name(std::move(name)), + vals({ + std::move(val), + }), + exportv(false) {} + + env_var_t() = default; + + bool empty() const { return vals.empty() || (vals.size() == 1 && vals[0].empty()); }; + bool read_only() const; bool matches_string(const wcstring &str) { if (vals.size() > 1) return false; @@ -110,12 +106,8 @@ class env_var_t { void set_vals(wcstring_list_t v) { vals = std::move(v); } - env_var_t &operator=(const env_var_t &var) { - this->name = var.name; - this->vals = var.vals; - this->exportv = var.exportv; - return *this; - } + env_var_t &operator=(const env_var_t &var) = default; + env_var_t &operator=(env_var_t &&) = default; /// Compare a simple string to the var. Returns true iff the var has a single /// value and that value matches the string being compared to.