diff options
| author | Maxime Coste <frrrwww@gmail.com> | 2014-10-07 21:11:55 +0100 |
|---|---|---|
| committer | Maxime Coste <frrrwww@gmail.com> | 2014-10-07 21:11:55 +0100 |
| commit | 8a7e16cec379f3f52a30ab2ce35b515914cdfcb4 (patch) | |
| tree | 21ffdc1a0c95e6699b2b8a6251d80bd8a7099e66 | |
| parent | a627eab57c0c149e493d22673ba23f3e010c881c (diff) | |
Switch some const String& parameters to StringView
| -rw-r--r-- | src/insert_completer.cc | 2 | ||||
| -rw-r--r-- | src/insert_completer.hh | 2 | ||||
| -rw-r--r-- | src/option_types.hh | 20 |
3 files changed, 12 insertions, 12 deletions
diff --git a/src/insert_completer.cc b/src/insert_completer.cc index b5be9c95..1e50d189 100644 --- a/src/insert_completer.cc +++ b/src/insert_completer.cc @@ -31,7 +31,7 @@ String option_to_string(const InsertCompleterDesc& opt) return ""; } -void option_from_string(const String& str, InsertCompleterDesc& opt) +void option_from_string(StringView str, InsertCompleterDesc& opt) { if (str.substr(0_byte, 7_byte) == "option=") { diff --git a/src/insert_completer.hh b/src/insert_completer.hh index 88759edf..d7580b64 100644 --- a/src/insert_completer.hh +++ b/src/insert_completer.hh @@ -37,7 +37,7 @@ using InsertCompleterDescList = std::vector<InsertCompleterDesc>; String option_to_string(const InsertCompleterDesc& opt); -void option_from_string(const String& str, InsertCompleterDesc& opt); +void option_from_string(StringView str, InsertCompleterDesc& opt); struct InsertCompletion { diff --git a/src/option_types.hh b/src/option_types.hh index 7b0ebbf1..ea3bd49a 100644 --- a/src/option_types.hh +++ b/src/option_types.hh @@ -13,15 +13,15 @@ namespace Kakoune { -inline String option_to_string(const String& opt) { return opt; } -inline void option_from_string(const String& str, String& opt) { opt = str; } +inline String option_to_string(StringView opt) { return opt; } +inline void option_from_string(StringView str, String& opt) { opt = str; } inline String option_to_string(int opt) { return to_string(opt); } -inline void option_from_string(const String& str, int& opt) { opt = str_to_int(str); } +inline void option_from_string(StringView str, int& opt) { opt = str_to_int(str); } inline bool option_add(int& opt, int val) { opt += val; return val != 0; } inline String option_to_string(bool opt) { return opt ? "true" : "false"; } -inline void option_from_string(const String& str, bool& opt) +inline void option_from_string(StringView str, bool& opt) { if (str == "true" or str == "yes") opt = true; @@ -47,7 +47,7 @@ String option_to_string(const std::vector<T>& opt) } template<typename T> -void option_from_string(const String& str, std::vector<T>& opt) +void option_from_string(StringView str, std::vector<T>& opt) { opt.clear(); std::vector<String> elems = split(str, list_separator, '\\'); @@ -80,7 +80,7 @@ String option_to_string(const std::unordered_set<T>& opt) } template<typename T> -void option_from_string(const String& str, std::unordered_set<T>& opt) +void option_from_string(StringView str, std::unordered_set<T>& opt) { opt.clear(); std::vector<String> elems = split(str, list_separator, '\\'); @@ -138,7 +138,7 @@ String option_to_string(const std::tuple<Types...>& opt) } template<typename... Types> -void option_from_string(const String& str, std::tuple<Types...>& opt) +void option_from_string(StringView str, std::tuple<Types...>& opt) { auto elems = split(str, tuple_separator, '\\'); if (elems.size() != sizeof...(Types)) @@ -153,7 +153,7 @@ inline String option_to_string(const StronglyTypedNumber<RealType, ValueType>& o } template<typename RealType, typename ValueType> -inline void option_from_string(const String& str, StronglyTypedNumber<RealType, ValueType>& opt) +inline void option_from_string(StringView str, StronglyTypedNumber<RealType, ValueType>& opt) { opt = StronglyTypedNumber<RealType, ValueType>{str_to_int(str)}; } @@ -173,7 +173,7 @@ bool option_add(T&, const T&) } template<typename EffectiveType, typename LineType, typename ColumnType> -inline void option_from_string(const String& str, LineAndColumn<EffectiveType, LineType, ColumnType>& opt) +inline void option_from_string(StringView str, LineAndColumn<EffectiveType, LineType, ColumnType>& opt) { auto vals = split(str, tuple_separator); if (vals.size() != 2) @@ -207,7 +207,7 @@ inline String option_to_string(YesNoAsk opt) return "ask"; } -inline void option_from_string(const String& str, YesNoAsk& opt) +inline void option_from_string(StringView str, YesNoAsk& opt) { if (str == "yes" or str == "true") opt = Yes; |
