Use the _str and _sv string literals more often
This commit is contained in:
parent
b4f8497f8d
commit
eeacb8b5a8
|
@ -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{[]()
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -50,8 +50,8 @@ UnitTest test_hash_map{[] {
|
|||
{
|
||||
HashMap<String, int> 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
|
||||
|
|
|
@ -880,7 +880,7 @@ int main(int argc, char* argv[])
|
|||
return 0;
|
||||
};
|
||||
|
||||
if (contains(ConstArrayView<char*>{argv+1, (size_t)argc-1}, StringView{"--help"}))
|
||||
if (contains(ConstArrayView<char*>{argv+1, (size_t)argc-1}, "--help"_sv))
|
||||
return show_usage();
|
||||
|
||||
ParametersParser parser{params, param_desc};
|
||||
|
|
|
@ -109,7 +109,7 @@ bool option_add(Vector<T, domain>& opt, StringView str)
|
|||
template<typename T, MemoryDomain D>
|
||||
String option_type_name(Meta::Type<Vector<T, D>>)
|
||||
{
|
||||
return option_type_name(Meta::Type<T>{}) + StringView{"-list"};
|
||||
return option_type_name(Meta::Type<T>{}) + "-list"_sv;
|
||||
}
|
||||
|
||||
template<typename Key, typename Value, MemoryDomain domain>
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user