From eeacb8b5a87da979d547a223cca6a319717281c8 Mon Sep 17 00:00:00 2001 From: Maxime Coste Date: Thu, 18 Jan 2018 09:00:54 +1100 Subject: [PATCH] Use the _str and _sv string literals more often --- src/buffer.cc | 8 ++++---- src/face_registry.cc | 2 +- src/hash_map.cc | 4 ++-- src/main.cc | 2 +- src/option_types.hh | 2 +- src/selectors.cc | 4 ++-- 6 files changed, 11 insertions(+), 11 deletions(-) diff --git a/src/buffer.cc b/src/buffer.cc index 0ffdb9ae..b0e70748 100644 --- a/src/buffer.cc +++ b/src/buffer.cc @@ -794,20 +794,20 @@ UnitTest test_buffer{[]() // check insert at end behaviour: auto add end of line if necessary pos = buffer.end()-1; buffer.insert(pos.coord(), "tchou"); - kak_assert(buffer.string(pos.coord(), buffer.end_coord()) == StringView{"tchou\n"}); + kak_assert(buffer.string(pos.coord(), buffer.end_coord()) == "tchou\n"_sv); pos = buffer.end()-1; buffer.insert(buffer.end_coord(), "kanaky\n"); - kak_assert(buffer.string((pos+1).coord(), buffer.end_coord()) == StringView{"kanaky\n"}); + kak_assert(buffer.string((pos+1).coord(), buffer.end_coord()) == "kanaky\n"_sv); buffer.commit_undo_group(); buffer.erase((pos+1).coord(), buffer.end_coord()); buffer.insert(buffer.end_coord(), "mutch\n"); buffer.commit_undo_group(); buffer.undo(); - kak_assert(buffer.string(buffer.advance(buffer.end_coord(), -7), buffer.end_coord()) == StringView{"kanaky\n"}); + kak_assert(buffer.string(buffer.advance(buffer.end_coord(), -7), buffer.end_coord()) == "kanaky\n"_sv); buffer.redo(); - kak_assert(buffer.string(buffer.advance(buffer.end_coord(), -6), buffer.end_coord()) == StringView{"mutch\n"}); + kak_assert(buffer.string(buffer.advance(buffer.end_coord(), -6), buffer.end_coord()) == "mutch\n"_sv); }}; UnitTest test_undo{[]() diff --git a/src/face_registry.cc b/src/face_registry.cc index b78f7f60..fa35be4b 100644 --- a/src/face_registry.cc +++ b/src/face_registry.cc @@ -63,7 +63,7 @@ String to_string(Attribute attributes) filter([=](const Attr& a) { return attributes & a.attr; }) | transform([](const Attr& a) { return a.name; }); - return accumulate(filteredAttrs, String{"+"}, std::plus<>{}); + return accumulate(filteredAttrs, "+"_str, std::plus<>{}); } String to_string(Face face) diff --git a/src/hash_map.cc b/src/hash_map.cc index 95b75f18..56189aef 100644 --- a/src/hash_map.cc +++ b/src/hash_map.cc @@ -50,8 +50,8 @@ UnitTest test_hash_map{[] { { HashMap map; map.insert({"test", 10}); - kak_assert(map[StringView{"test"}] == 10); - map.remove(StringView{"test"}); + kak_assert(map["test"_sv] == 10); + map.remove("test"_sv); } // make sure we get what we expect from the hash map diff --git a/src/main.cc b/src/main.cc index 0ba1cf6f..b9f995f6 100644 --- a/src/main.cc +++ b/src/main.cc @@ -880,7 +880,7 @@ int main(int argc, char* argv[]) return 0; }; - if (contains(ConstArrayView{argv+1, (size_t)argc-1}, StringView{"--help"})) + if (contains(ConstArrayView{argv+1, (size_t)argc-1}, "--help"_sv)) return show_usage(); ParametersParser parser{params, param_desc}; diff --git a/src/option_types.hh b/src/option_types.hh index 0c3fc3e3..1e736436 100644 --- a/src/option_types.hh +++ b/src/option_types.hh @@ -109,7 +109,7 @@ bool option_add(Vector& opt, StringView str) template String option_type_name(Meta::Type>) { - return option_type_name(Meta::Type{}) + StringView{"-list"}; + return option_type_name(Meta::Type{}) + "-list"_sv; } template diff --git a/src/selectors.cc b/src/selectors.cc index 3a200c2f..84be47b6 100644 --- a/src/selectors.cc +++ b/src/selectors.cc @@ -671,7 +671,7 @@ select_indent(const Context& context, const Selection& selection, LineCount begin_line = line - 1; if (to_begin) { - while (begin_line >= 0 and (buffer[begin_line] == StringView{"\n"} or + while (begin_line >= 0 and (buffer[begin_line] == "\n"_sv or get_indent(buffer[begin_line], tabstop) >= indent)) --begin_line; } @@ -680,7 +680,7 @@ select_indent(const Context& context, const Selection& selection, if (to_end) { const LineCount end = buffer.line_count(); - while (end_line < end and (buffer[end_line] == StringView{"\n"} or + while (end_line < end and (buffer[end_line] == "\n"_sv or get_indent(buffer[end_line], tabstop) >= indent)) ++end_line; }