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
|
// check insert at end behaviour: auto add end of line if necessary
|
||||||
pos = buffer.end()-1;
|
pos = buffer.end()-1;
|
||||||
buffer.insert(pos.coord(), "tchou");
|
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;
|
pos = buffer.end()-1;
|
||||||
buffer.insert(buffer.end_coord(), "kanaky\n");
|
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.commit_undo_group();
|
||||||
buffer.erase((pos+1).coord(), buffer.end_coord());
|
buffer.erase((pos+1).coord(), buffer.end_coord());
|
||||||
buffer.insert(buffer.end_coord(), "mutch\n");
|
buffer.insert(buffer.end_coord(), "mutch\n");
|
||||||
buffer.commit_undo_group();
|
buffer.commit_undo_group();
|
||||||
buffer.undo();
|
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();
|
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{[]()
|
UnitTest test_undo{[]()
|
||||||
|
|
|
@ -63,7 +63,7 @@ String to_string(Attribute attributes)
|
||||||
filter([=](const Attr& a) { return attributes & a.attr; }) |
|
filter([=](const Attr& a) { return attributes & a.attr; }) |
|
||||||
transform([](const Attr& a) { return a.name; });
|
transform([](const Attr& a) { return a.name; });
|
||||||
|
|
||||||
return accumulate(filteredAttrs, String{"+"}, std::plus<>{});
|
return accumulate(filteredAttrs, "+"_str, std::plus<>{});
|
||||||
}
|
}
|
||||||
|
|
||||||
String to_string(Face face)
|
String to_string(Face face)
|
||||||
|
|
|
@ -50,8 +50,8 @@ UnitTest test_hash_map{[] {
|
||||||
{
|
{
|
||||||
HashMap<String, int> map;
|
HashMap<String, int> map;
|
||||||
map.insert({"test", 10});
|
map.insert({"test", 10});
|
||||||
kak_assert(map[StringView{"test"}] == 10);
|
kak_assert(map["test"_sv] == 10);
|
||||||
map.remove(StringView{"test"});
|
map.remove("test"_sv);
|
||||||
}
|
}
|
||||||
|
|
||||||
// make sure we get what we expect from the hash map
|
// make sure we get what we expect from the hash map
|
||||||
|
|
|
@ -880,7 +880,7 @@ int main(int argc, char* argv[])
|
||||||
return 0;
|
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();
|
return show_usage();
|
||||||
|
|
||||||
ParametersParser parser{params, param_desc};
|
ParametersParser parser{params, param_desc};
|
||||||
|
|
|
@ -109,7 +109,7 @@ bool option_add(Vector<T, domain>& opt, StringView str)
|
||||||
template<typename T, MemoryDomain D>
|
template<typename T, MemoryDomain D>
|
||||||
String option_type_name(Meta::Type<Vector<T, 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>
|
template<typename Key, typename Value, MemoryDomain domain>
|
||||||
|
|
|
@ -671,7 +671,7 @@ select_indent(const Context& context, const Selection& selection,
|
||||||
LineCount begin_line = line - 1;
|
LineCount begin_line = line - 1;
|
||||||
if (to_begin)
|
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))
|
get_indent(buffer[begin_line], tabstop) >= indent))
|
||||||
--begin_line;
|
--begin_line;
|
||||||
}
|
}
|
||||||
|
@ -680,7 +680,7 @@ select_indent(const Context& context, const Selection& selection,
|
||||||
if (to_end)
|
if (to_end)
|
||||||
{
|
{
|
||||||
const LineCount end = buffer.line_count();
|
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))
|
get_indent(buffer[end_line], tabstop) >= indent))
|
||||||
++end_line;
|
++end_line;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user