Everywhere: Replace single-char StringView op. arguments with chars

This prevents us from needing a sv suffix, and potentially reduces the
need to run generic code for a single character (as contains,
starts_with, ends_with etc. for a char will be just a length and
equality check).

No functional changes.
This commit is contained in:
sin-ack 2022-07-11 20:10:18 +00:00 committed by Andreas Kling
parent 3f3f45580a
commit c8585b77d2
86 changed files with 283 additions and 283 deletions

View file

@ -182,9 +182,9 @@ inline void JsonValue::serialize(Builder& builder) const
{
switch (m_type) {
case Type::String: {
builder.append("\"");
builder.append('\"');
builder.append_escaped_for_json({ m_value.as_string->characters(), m_value.as_string->length() });
builder.append("\"");
builder.append('\"');
} break;
case Type::Array:
m_value.as_array->serialize(builder);

View file

@ -75,7 +75,7 @@ public:
if (string.is_null())
return {};
auto const parts = string.split_view(":");
auto const parts = string.split_view(':');
if (parts.size() != 6)
return {};

View file

@ -58,7 +58,7 @@ UNMAP_AFTER_INIT NonnullOwnPtr<KString> CommandLine::build_commandline(StringVie
StringBuilder builder;
builder.append(cmdline_from_bootloader);
if constexpr (!s_embedded_cmd_line.is_empty()) {
builder.append(" ");
builder.append(' ');
builder.append(s_embedded_cmd_line);
}
return KString::must_create(builder.string_view());

View file

@ -60,7 +60,7 @@ static String convert_enumeration_value_to_cpp_enum_member(String const& value,
} else {
auto non_alnum_string = lexer.consume_while([](auto c) { return !is_ascii_alphanumeric(c); });
if (!non_alnum_string.is_empty())
builder.append("_");
builder.append('_');
}
}

View file

@ -100,7 +100,7 @@ static void do_weird_call(size_t attempt, int syscall_fn, size_t arg1, size_t ar
builder.append(", "sv);
builder.appendff("{:p}", fake_params[i]);
}
builder.append("]");
builder.append(']');
dbgln("{}", builder.build());
// Actually do the syscall ('fake_params' is passed indirectly, if any of arg1, arg2, or arg3 point to it.

View file

@ -159,7 +159,7 @@ TEST_CASE(parser_error_special_characters_used_at_wrong_place)
// After circumflex
b.clear();
b.append("^");
b.append('^');
b.append(ch);
pattern = b.build();
l.set_source(pattern);
@ -169,7 +169,7 @@ TEST_CASE(parser_error_special_characters_used_at_wrong_place)
// After dollar
b.clear();
b.append("$");
b.append('$');
b.append(ch);
pattern = b.build();
l.set_source(pattern);
@ -179,9 +179,9 @@ TEST_CASE(parser_error_special_characters_used_at_wrong_place)
// After left parens
b.clear();
b.append("(");
b.append('(');
b.append(ch);
b.append(")");
b.append(')');
pattern = b.build();
l.set_source(pattern);
p.parse();

View file

@ -341,7 +341,7 @@ TEST_CASE(parser_error_special_characters_used_at_wrong_place)
// After circumflex
b.clear();
b.append("^");
b.append('^');
b.append(ch);
pattern = b.build();
EXPECT_EQ(regcomp(&regex, pattern.characters(), REG_EXTENDED), error_code_to_check);
@ -350,7 +350,7 @@ TEST_CASE(parser_error_special_characters_used_at_wrong_place)
// After dollar
b.clear();
b.append("$");
b.append('$');
b.append(ch);
pattern = b.build();
EXPECT_EQ(regcomp(&regex, pattern.characters(), REG_EXTENDED), error_code_to_check);
@ -359,9 +359,9 @@ TEST_CASE(parser_error_special_characters_used_at_wrong_place)
// After left parens
b.clear();
b.append("(");
b.append('(');
b.append(ch);
b.append(")");
b.append(')');
pattern = b.build();
EXPECT_EQ(regcomp(&regex, pattern.characters(), REG_EXTENDED), error_code_to_check);
EXPECT_EQ(regexec(&regex, "test", num_matches, matches, 0), error_code_to_check);

View file

@ -73,13 +73,13 @@ GUI::Variant ClipboardHistoryModel::data(const GUI::ModelIndex& index, GUI::Mode
return String::copy(data_and_type.data);
if (data_and_type.mime_type == "image/x-serenityos") {
StringBuilder builder;
builder.append("[");
builder.append('[');
builder.append(data_and_type.metadata.get("width").value_or("?"));
builder.append('x');
builder.append(data_and_type.metadata.get("height").value_or("?"));
builder.append('x');
builder.append(bpp_for_format_resilient(data_and_type.metadata.get("format").value_or("0")));
builder.append("]");
builder.append(']');
builder.append(" bitmap"sv);
return builder.to_string();
}

View file

@ -28,7 +28,7 @@ RefPtr<Mesh> WavefrontOBJLoader::load(Core::File& file)
// Start reading file line by line
for (auto object_line : file.lines()) {
// Ignore file comments
if (object_line.starts_with("#"))
if (object_line.starts_with('#'))
continue;
if (object_line.starts_with("vt"sv)) {
@ -59,7 +59,7 @@ RefPtr<Mesh> WavefrontOBJLoader::load(Core::File& file)
}
// This line describes a vertex (a position in 3D space)
if (object_line.starts_with("v")) {
if (object_line.starts_with('v')) {
auto vertex_line = object_line.split_view(' ');
if (vertex_line.size() != 4) {
dbgln("Wavefront: Malformed vertex line. Aborting.");
@ -74,7 +74,7 @@ RefPtr<Mesh> WavefrontOBJLoader::load(Core::File& file)
}
// This line describes a face (a collection of 3+ vertices, aka a triangle or polygon)
if (object_line.starts_with("f")) {
if (object_line.starts_with('f')) {
auto face_line = object_line.substring_view(2).split_view(' ');
auto number_of_vertices = face_line.size();
if (number_of_vertices < 3) {

View file

@ -62,7 +62,7 @@ void URLResult::activate() const
void AppProvider::query(String const& query, Function<void(NonnullRefPtrVector<Result>)> on_complete)
{
if (query.starts_with("=") || query.starts_with('$'))
if (query.starts_with('=') || query.starts_with('$'))
return;
NonnullRefPtrVector<Result> results;
@ -81,7 +81,7 @@ void AppProvider::query(String const& query, Function<void(NonnullRefPtrVector<R
void CalculatorProvider::query(String const& query, Function<void(NonnullRefPtrVector<Result>)> on_complete)
{
if (!query.starts_with("="))
if (!query.starts_with('='))
return;
auto vm = JS::VM::create();

View file

@ -121,7 +121,7 @@ String Keypad::to_string() const
{
StringBuilder builder;
if (m_negative)
builder.append("-");
builder.append('-');
builder.appendff("{}", m_int_value.value());
// NOTE: This is so the decimal point appears on screen as soon as you type it.

View file

@ -209,7 +209,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
};
auto& arguments_label = *widget->find_descendant_of_type_named<GUI::Label>("arguments_label");
arguments_label.set_text(String::join(" ", crashed_process_arguments));
arguments_label.set_text(String::join(' ', crashed_process_arguments));
auto& progressbar = *widget->find_descendant_of_type_named<GUI::Progressbar>("progressbar");
auto& tab_widget = *widget->find_descendant_of_type_named<GUI::TabWidget>("tab_widget");
@ -241,7 +241,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
environment_tab->layout()->set_margins(4);
auto environment_text_editor = TRY(environment_tab->try_add<GUI::TextEditor>());
environment_text_editor->set_text(String::join("\n", environment));
environment_text_editor->set_text(String::join('\n', environment));
environment_text_editor->set_mode(GUI::TextEditor::Mode::ReadOnly);
environment_text_editor->set_should_hide_unnecessary_scrollbars(true);
@ -250,7 +250,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
memory_regions_tab->layout()->set_margins(4);
auto memory_regions_text_editor = TRY(memory_regions_tab->try_add<GUI::TextEditor>());
memory_regions_text_editor->set_text(String::join("\n", memory_regions));
memory_regions_text_editor->set_text(String::join('\n', memory_regions));
memory_regions_text_editor->set_mode(GUI::TextEditor::Mode::ReadOnly);
memory_regions_text_editor->set_should_hide_unnecessary_scrollbars(true);
memory_regions_text_editor->set_visualize_trailing_whitespace(false);

View file

@ -201,7 +201,7 @@ void do_create_archive(Vector<String> const& selected_file_paths, GUI::Window* w
StringBuilder path_builder;
path_builder.append(output_directory_path.dirname());
path_builder.append("/");
path_builder.append('/');
if (archive_name.is_empty()) {
path_builder.append(output_directory_path.parent().basename());
path_builder.append(".zip"sv);

View file

@ -849,7 +849,7 @@ void MainWidget::update_statusbar()
builder.append_code_point(glyph);
}
builder.append(")");
builder.append(')');
auto glyph_name = Unicode::code_point_display_name(glyph);
if (glyph_name.has_value()) {

View file

@ -169,7 +169,7 @@ struct QueueEntry {
static void populate_filesize_tree(TreeNode& root, Vector<MountInfo>& mounts, HashMap<int, int>& error_accumulator, GUI::Label& progresslabel)
{
VERIFY(!root.m_name.ends_with("/"));
VERIFY(!root.m_name.ends_with('/'));
Queue<QueueEntry> queue;
queue.enqueue(QueueEntry(root.m_name, &root));
@ -177,7 +177,7 @@ static void populate_filesize_tree(TreeNode& root, Vector<MountInfo>& mounts, Ha
StringBuilder builder = StringBuilder();
builder.append(root.m_name);
builder.append("/");
builder.append('/');
MountInfo* root_mount_info = find_mount_for_path(builder.to_string(), mounts);
if (!root_mount_info) {
return;
@ -187,7 +187,7 @@ static void populate_filesize_tree(TreeNode& root, Vector<MountInfo>& mounts, Ha
builder.clear();
builder.append(queue_entry.path);
builder.append("/");
builder.append('/');
MountInfo* mount_info = find_mount_for_path(builder.to_string(), mounts);
if (!mount_info || (mount_info != root_mount_info && mount_info->source != root_mount_info->source)) {
@ -269,7 +269,7 @@ static void analyze(RefPtr<Tree> tree, SpaceAnalyzer::TreeMapWidget& treemapwidg
} else {
builder.append(" times"sv);
}
builder.append(")");
builder.append(')');
first = false;
}
statusbar.set_text(builder.to_string());
@ -404,7 +404,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
const SpaceAnalyzer::TreeMapNode* node = treemapwidget.path_node(k);
builder.append("/");
builder.append('/');
builder.append(node->name());
breadcrumbbar.append_segment(node->name(), GUI::FileIconProvider::icon_for_path(builder.string_view()).bitmap_for_size(16), builder.string_view(), builder.string_view());

View file

@ -22,7 +22,7 @@ void Cell::set_data(String new_data)
if (m_data == new_data)
return;
if (new_data.starts_with("=")) {
if (new_data.starts_with('=')) {
new_data = new_data.substring(1, new_data.length() - 1);
m_kind = Formula;
} else {

View file

@ -140,7 +140,7 @@ private:
auto string = String::formatted("{}", FormatIfSupported(entry));
auto safe_to_write_normally = (m_behaviors & WriterBehavior::QuoteAll) == WriterBehavior::None
&& !string.contains("\n")
&& !string.contains('\n')
&& !string.contains(m_traits.separator);
if (safe_to_write_normally) {

View file

@ -226,9 +226,9 @@ public:
"Size", Gfx::TextAlignment::CenterRight,
[](const JsonObject& object) {
StringBuilder size_builder;
size_builder.append(" ");
size_builder.append(' ');
size_builder.append(human_readable_size(object.get("total_block_count"sv).to_u64() * object.get("block_size"sv).to_u64()));
size_builder.append(" ");
size_builder.append(' ');
return size_builder.to_string();
},
[](const JsonObject& object) {

View file

@ -94,7 +94,7 @@ bool Debugger::set_execution_position(String const& file, size_t line)
Debug::DebugInfo::SourcePosition Debugger::create_source_position(String const& file, size_t line)
{
if (file.starts_with("/"))
if (file.starts_with('/'))
return { file, line + 1 };
return { LexicalPath::canonicalized_path(String::formatted("{}/{}", m_source_root, file)), line + 1 };
}

View file

@ -161,7 +161,7 @@ Optional<String> NewProjectDialog::get_available_project_name()
Optional<String> NewProjectDialog::get_project_full_path()
{
// Do not permit forward-slashes in project names
if (m_name_input->text().contains("/"))
if (m_name_input->text().contains('/'))
return {};
auto create_in = m_create_in_input->text();

View file

@ -619,7 +619,7 @@ NonnullRefPtr<GUI::Action> HackStudioWidget::create_copy_relative_path_action()
auto copy_relative_path_action = GUI::Action::create("Copy &Relative Path", [this](const GUI::Action&) {
auto paths = selected_file_paths();
VERIFY(!paths.is_empty());
auto paths_string = String::join("\n", paths);
auto paths_string = String::join('\n', paths);
GUI::Clipboard::the().set_plain_text(paths_string);
});
copy_relative_path_action->set_enabled(true);
@ -636,7 +636,7 @@ NonnullRefPtr<GUI::Action> HackStudioWidget::create_copy_full_path_action()
Vector<String> full_paths;
for (auto& path : paths)
full_paths.append(get_absolute_path(path));
auto paths_string = String::join("\n", full_paths);
auto paths_string = String::join('\n', full_paths);
GUI::Clipboard::the().set_plain_text(paths_string);
});
copy_full_path_action->set_enabled(true);
@ -1086,7 +1086,7 @@ String HackStudioWidget::get_full_path_of_serenity_source(String const& file)
path_parts.remove(0);
}
StringBuilder relative_path_builder;
relative_path_builder.join("/", path_parts);
relative_path_builder.join('/', path_parts);
constexpr char SERENITY_LIBS_PREFIX[] = "/usr/src/serenity";
LexicalPath serenity_sources_base(SERENITY_LIBS_PREFIX);
return String::formatted("{}/{}", serenity_sources_base, relative_path_builder.to_string());

View file

@ -15,7 +15,7 @@ Language language_from_file(LexicalPath const& file)
return Language::GitCommit;
auto extension = file.extension();
VERIFY(!extension.starts_with("."));
VERIFY(!extension.starts_with('.'));
if (extension == "c" || extension == "cc" || extension == "cxx" || extension == "cpp" || extension == "c++"
|| extension == "h" || extension == "hh" || extension == "hxx" || extension == "hpp" || extension == "h++")
return Language::Cpp;
@ -57,7 +57,7 @@ String language_name_from_file(LexicalPath const& file)
return "GitCommit";
auto extension = file.extension();
VERIFY(!extension.starts_with("."));
VERIFY(!extension.starts_with('.'));
if (extension == "c" || extension == "cc" || extension == "cxx" || extension == "cpp" || extension == "c++"
|| extension == "h" || extension == "hh" || extension == "hxx" || extension == "hpp" || extension == "h++")
return "C++";

View file

@ -246,7 +246,7 @@ void ProjectBuilder::for_each_library_dependencies(Function<void(String, Vector<
auto library_name = result.capture_group_matches.at(0).at(0).view.string_view();
auto dependencies_string = result.capture_group_matches.at(0).at(1).view.string_view();
func(library_name, dependencies_string.split_view(" "));
func(library_name, dependencies_string.split_view(' '));
}
}

View file

@ -127,7 +127,7 @@ static void update_path_environment_variable()
path.append({ path_env_ptr, strlen(path_env_ptr) });
if (path.length())
path.append(":");
path.append(':');
path.append("/usr/local/sbin:/usr/local/bin:/usr/bin:/bin"sv);
setenv("PATH", path.to_string().characters(), true);
}

View file

@ -35,7 +35,7 @@ FileEventNode& FileEventNode::find_or_create_node(String const& searched_path)
auto current = parts.take_first();
StringBuilder sb;
sb.join("/", parts);
sb.join('/', parts);
auto new_s = sb.to_string();
for (auto& child : m_children) {
@ -75,7 +75,7 @@ FileEventNode& FileEventNode::create_recursively(String new_path)
m_children.append(new_node);
StringBuilder sb;
sb.join("/", parts);
sb.join('/', parts);
return new_node->create_recursively(sb.to_string());
}

View file

@ -555,45 +555,45 @@ bool ChessWidget::import_pgn(StringView import_path)
token = token.trim_whitespace();
// FIXME: Parse all of these tokens when we start caring about them
if (token.ends_with("}")) {
if (token.ends_with('}')) {
skip = false;
continue;
}
if (skip)
continue;
if (token.starts_with("{")) {
if (token.ends_with("}"))
if (token.starts_with('{')) {
if (token.ends_with('}'))
continue;
skip = true;
continue;
}
if (token.ends_with(")")) {
if (token.ends_with(')')) {
recursive_annotation = false;
continue;
}
if (recursive_annotation)
continue;
if (token.starts_with("(")) {
if (token.ends_with(")"))
if (token.starts_with('(')) {
if (token.ends_with(')'))
continue;
recursive_annotation = true;
continue;
}
if (token.ends_with(">")) {
if (token.ends_with('>')) {
future_expansion = false;
continue;
}
if (future_expansion)
continue;
if (token.starts_with("<")) {
if (token.ends_with(">"))
if (token.starts_with('<')) {
if (token.ends_with('>'))
continue;
future_expansion = true;
continue;
}
if (token.starts_with("$"))
if (token.starts_with('$'))
continue;
if (token.contains("*"))
if (token.contains('*'))
break;
// FIXME: When we become able to set more of the game state, fix these end results
if (token.contains("1-0"sv)) {
@ -607,7 +607,7 @@ bool ChessWidget::import_pgn(StringView import_path)
if (token.contains("1/2-1/2"sv)) {
break;
}
if (!token.ends_with(".")) {
if (!token.ends_with('.')) {
m_board.apply_move(Chess::Move::from_algebraic(token, turn, m_board));
turn = Chess::opposing_color(turn);
}

View file

@ -106,7 +106,7 @@ Move Move::from_algebraic(StringView algebraic, const Color turn, Board const& b
String move_string = algebraic;
Move move({ 50, 50 }, { 50, 50 });
if (move_string.contains("-")) {
if (move_string.contains('-')) {
move.from = Square(turn == Color::White ? 0 : 7, 4);
move.to = Square(turn == Color::White ? 0 : 7, move_string == "O-O" ? 6 : 2);
move.promote_to = Type::None;
@ -115,15 +115,15 @@ Move Move::from_algebraic(StringView algebraic, const Color turn, Board const& b
return move;
}
if (algebraic.contains("#")) {
if (algebraic.contains('#')) {
move.is_mate = true;
move_string = move_string.substring(0, move_string.length() - 1);
} else if (algebraic.contains("+")) {
} else if (algebraic.contains('+')) {
move.is_check = true;
move_string = move_string.substring(0, move_string.length() - 1);
}
if (algebraic.contains("=")) {
if (algebraic.contains('=')) {
move.promote_to = piece_for_char_promotion(move_string.split('=').at(1).substring(0, 1));
move_string = move_string.split('=').at(0);
}
@ -131,7 +131,7 @@ Move Move::from_algebraic(StringView algebraic, const Color turn, Board const& b
move.to = Square(move_string.substring(move_string.length() - 2, 2));
move_string = move_string.substring(0, move_string.length() - 2);
if (move_string.contains("x")) {
if (move_string.contains('x')) {
move.is_capture = true;
move_string = move_string.substring(0, move_string.length() - 1);
}
@ -201,20 +201,20 @@ String Move::to_algebraic() const
if (is_capture) {
if (piece.type == Type::Pawn && !is_ambiguous)
builder.append(from.to_algebraic().substring(0, 1));
builder.append("x");
builder.append('x');
}
builder.append(to.to_algebraic());
if (promote_to != Type::None) {
builder.append("=");
builder.append('=');
builder.append(char_for_piece(promote_to));
}
if (is_mate)
builder.append("#");
builder.append('#');
else if (is_check)
builder.append("+");
builder.append('+');
return builder.build();
}
@ -287,7 +287,7 @@ String Board::to_fen() const
empty = 0;
}
if (rank < 7)
builder.append("/");
builder.append('/');
}
// 2. Active color
@ -299,26 +299,26 @@ String Board::to_fen() const
builder.append(m_white_can_castle_queenside ? "Q"sv : ""sv);
builder.append(m_black_can_castle_kingside ? "k"sv : ""sv);
builder.append(m_black_can_castle_queenside ? "q"sv : ""sv);
builder.append(" ");
builder.append(' ');
// 4. En passant target square
if (!m_last_move.has_value())
builder.append("-");
builder.append('-');
else if (m_last_move.value().piece.type == Type::Pawn) {
if (m_last_move.value().from.rank == 1 && m_last_move.value().to.rank == 3)
builder.append(Square(m_last_move.value().to.rank - 1, m_last_move.value().to.file).to_algebraic());
else if (m_last_move.value().from.rank == 6 && m_last_move.value().to.rank == 4)
builder.append(Square(m_last_move.value().to.rank + 1, m_last_move.value().to.file).to_algebraic());
else
builder.append("-");
builder.append('-');
} else {
builder.append("-");
builder.append('-');
}
builder.append(" ");
builder.append(' ');
// 5. Halfmove clock
builder.append(String::number(min(m_moves_since_capture, m_moves_since_pawn_advance)));
builder.append(" ");
builder.append(' ');
// 6. Fullmove number
builder.append(String::number(1 + m_moves.size() / 2));

View file

@ -695,16 +695,16 @@ Optional<Vector<CodeComprehension::AutocompleteResultEntry>> CppComprehensionEng
String include_root;
bool already_has_suffix = false;
if (partial_include.starts_with("<")) {
if (partial_include.starts_with('<')) {
include_root = "/usr/include/";
include_type = System;
if (partial_include.ends_with(">")) {
if (partial_include.ends_with('>')) {
already_has_suffix = true;
partial_include = partial_include.substring_view(0, partial_include.length() - 1).trim_whitespace();
}
} else if (partial_include.starts_with("\"")) {
} else if (partial_include.starts_with('"')) {
include_root = filedb().project_root();
if (partial_include.length() > 1 && partial_include.ends_with("\"")) {
if (partial_include.length() > 1 && partial_include.ends_with('\"')) {
already_has_suffix = true;
partial_include = partial_include.substring_view(0, partial_include.length() - 1).trim_whitespace();
}
@ -923,7 +923,7 @@ Optional<CppComprehensionEngine::FunctionParamsHint> CppComprehensionEngine::get
for (auto token : document_of_declaration->parser().tokens_in_range(arg.start(), arg.end())) {
tokens_text.append(token.text());
}
hint.params.append(String::join(" ", tokens_text));
hint.params.append(String::join(' ', tokens_text));
}
return hint;

View file

@ -80,7 +80,7 @@ Vector<String> const& ShellComprehensionEngine::DocumentData::sourced_paths() co
return;
auto name_list = const_cast<::Shell::AST::Node*>(filename.ptr())->run(nullptr)->resolve_as_list(nullptr);
StringBuilder builder;
builder.join(" ", name_list);
builder.join(' ', name_list);
sourced_files.set(builder.build());
}
}

View file

@ -763,7 +763,7 @@ void ArgsParser::autocomplete(FILE* file, StringView program_name, Span<char con
continue;
}
if (argument.starts_with("-")) {
if (argument.starts_with('-')) {
option_to_complete = argument;
completing_option = true;

View file

@ -153,7 +153,7 @@ String Backtrace::Entry::to_string(bool color) const
}
}
builder.append(")");
builder.append(')');
return builder.build();
}

View file

@ -35,7 +35,7 @@ void FunctionDeclaration::dump(FILE* output, size_t indent) const
String qualifiers_string;
if (!m_qualifiers.is_empty()) {
print_indent(output, indent + 1);
outln(output, "[{}]", String::join(" ", m_qualifiers));
outln(output, "[{}]", String::join(' ', m_qualifiers));
}
m_return_type->dump(output, indent + 1);
@ -79,7 +79,7 @@ String NamedType::to_string() const
{
String qualifiers_string;
if (!qualifiers().is_empty())
qualifiers_string = String::formatted("[{}] ", String::join(" ", qualifiers()));
qualifiers_string = String::formatted("[{}] ", String::join(' ', qualifiers()));
String name;
if (is_auto())
@ -96,7 +96,7 @@ String Pointer::to_string() const
return {};
StringBuilder builder;
builder.append(m_pointee->to_string());
builder.append("*");
builder.append('*');
return builder.to_string();
}
@ -107,7 +107,7 @@ String Reference::to_string() const
StringBuilder builder;
builder.append(m_referenced_type->to_string());
if (m_kind == Kind::Lvalue)
builder.append("&");
builder.append('&');
else
builder.append("&&"sv);
return builder.to_string();
@ -117,7 +117,7 @@ String FunctionType::to_string() const
{
StringBuilder builder;
builder.append(m_return_type->to_string());
builder.append("(");
builder.append('(');
bool first = true;
for (auto& parameter : m_parameters) {
if (first)
@ -127,11 +127,11 @@ String FunctionType::to_string() const
if (parameter.type())
builder.append(parameter.type()->to_string());
if (parameter.name() && !parameter.full_name().is_empty()) {
builder.append(" ");
builder.append(' ');
builder.append(parameter.full_name());
}
}
builder.append(")");
builder.append(')');
return builder.to_string();
}

View file

@ -132,7 +132,7 @@ Optional<DebugInfo::SourcePosition> DebugInfo::get_source_position(FlatPtr targe
Optional<DebugInfo::SourcePositionAndAddress> DebugInfo::get_address_from_source_position(String const& file, size_t line) const
{
String file_path = file;
if (!file_path.starts_with("/"))
if (!file_path.starts_with('/'))
file_path = String::formatted("/{}", file_path);
constexpr auto SERENITY_LIBS_PREFIX = "/usr/src/serenity"sv;
@ -326,9 +326,9 @@ void DebugInfo::add_type_info_to_variable(Dwarf::DIE const& type_die, PtraceRegi
StringBuilder array_type_name;
array_type_name.append(type_info->type_name);
for (auto array_size : type_info->dimension_sizes) {
array_type_name.append("[");
array_type_name.append('[');
array_type_name.append(String::formatted("{:d}", array_size));
array_type_name.append("]");
array_type_name.append(']');
}
parent_variable->type_name = array_type_name.to_string();
}

View file

@ -438,7 +438,7 @@ void DebugSession::update_loaded_libs()
if (!rc)
return {};
auto lib_name = result.capture_group_matches.at(0).at(0).view.string_view().to_string();
if (lib_name.starts_with("/"))
if (lib_name.starts_with('/'))
return lib_name;
return String::formatted("/usr/lib/{}", lib_name);
};

View file

@ -1221,7 +1221,7 @@ void GLContext::build_extension_string()
if (m_device_info.num_texture_units > 1)
extensions.append("GL_ARB_multitexture"sv);
m_extensions = String::join(" ", extensions);
m_extensions = String::join(' ', extensions);
}
NonnullOwnPtr<GLContext> create_context(Gfx::Bitmap& bitmap)

View file

@ -324,7 +324,7 @@ void ColorPicker::build_ui_custom(Widget& root_container)
m_html_text->on_change = [this]() {
auto color_name = m_html_text->text();
auto optional_color = Color::from_string(color_name);
if (optional_color.has_value() && (!color_name.starts_with("#") || color_name.length() == ((m_color_has_alpha_channel) ? 9 : 7))) {
if (optional_color.has_value() && (!color_name.starts_with('#') || color_name.length() == ((m_color_has_alpha_channel) ? 9 : 7))) {
// The color length must be 9/7 (unless it is a name like red), because:
// - If we allowed 5/4 character rgb color, the field would reset to 9/7 characters after you deleted 4/3 characters.
auto color = optional_color.value();

View file

@ -296,21 +296,21 @@ static String permission_string(mode_t mode)
{
StringBuilder builder;
if (S_ISDIR(mode))
builder.append("d");
builder.append('d');
else if (S_ISLNK(mode))
builder.append("l");
builder.append('l');
else if (S_ISBLK(mode))
builder.append("b");
builder.append('b');
else if (S_ISCHR(mode))
builder.append("c");
builder.append('c');
else if (S_ISFIFO(mode))
builder.append("f");
builder.append('f');
else if (S_ISSOCK(mode))
builder.append("s");
builder.append('s');
else if (S_ISREG(mode))
builder.append("-");
builder.append('-');
else
builder.append("?");
builder.append('?');
builder.append(mode & S_IRUSR ? 'r' : '-');
builder.append(mode & S_IWUSR ? 'w' : '-');
@ -384,7 +384,7 @@ void FileSystemModel::handle_file_event(Core::FileWatcherEvent const& event)
LexicalPath path { event.event_path };
auto& parts = path.parts_view();
StringView child_name = parts.last();
if (!m_should_show_dotfiles && child_name.starts_with("."))
if (!m_should_show_dotfiles && child_name.starts_with('.'))
break;
auto parent_name = path.parent().string();

View file

@ -79,7 +79,7 @@ public:
indent(builder, indentation);
builder.append(m_text);
}
builder.append("\n");
builder.append('\n');
}
virtual ~Comment() override = default;
@ -103,7 +103,7 @@ public:
builder.appendff("{}: ", m_key);
m_value->format(builder, indentation, true);
if (!is_inline)
builder.append("\n");
builder.append('\n');
}
String key() const { return m_key; }
@ -132,7 +132,7 @@ public:
if (is_array()) {
// custom array serialization as AK's doesn't pretty-print
// objects and arrays (we only care about arrays (for now))
builder.append("[");
builder.append('[');
auto first = true;
as_array().for_each([&](auto& value) {
if (!first)
@ -140,12 +140,12 @@ public:
first = false;
value.serialize(builder);
});
builder.append("]");
builder.append(']');
} else {
serialize(builder);
}
if (!is_inline)
builder.append("\n");
builder.append('\n');
}
};

View file

@ -61,9 +61,9 @@ private:
StringBuilder builder;
builder.append(action.text());
if (action.shortcut().is_valid()) {
builder.append(" (");
builder.append(" ("sv);
builder.append(action.shortcut().to_string());
builder.append(")");
builder.append(')');
}
return builder.to_string();
}

View file

@ -62,7 +62,7 @@ void Document::read_lines(StringView source)
continue;
}
if (line.starts_with("*")) {
if (line.starts_with('*')) {
if (!m_inside_unordered_list)
m_lines.append(make<Control>(Control::UnorderedListStart));
m_lines.append(make<UnorderedList>(move(line)));
@ -72,12 +72,12 @@ void Document::read_lines(StringView source)
close_list_if_needed();
if (line.starts_with("=>")) {
if (line.starts_with("=>"sv)) {
m_lines.append(make<Link>(move(line), *this));
continue;
}
if (line.starts_with("#")) {
if (line.starts_with('#')) {
size_t level = 0;
while (line.length() > level && line[level] == '#')
++level;

View file

@ -30,7 +30,7 @@ String Color::to_string_without_alpha() const
static Optional<Color> parse_rgb_color(StringView string)
{
VERIFY(string.starts_with("rgb("sv, CaseSensitivity::CaseInsensitive));
VERIFY(string.ends_with(")"));
VERIFY(string.ends_with(')'));
auto substring = string.substring_view(4, string.length() - 5);
auto parts = substring.split_view(',');
@ -51,7 +51,7 @@ static Optional<Color> parse_rgb_color(StringView string)
static Optional<Color> parse_rgba_color(StringView string)
{
VERIFY(string.starts_with("rgba("sv, CaseSensitivity::CaseInsensitive));
VERIFY(string.ends_with(")"));
VERIFY(string.ends_with(')'));
auto substring = string.substring_view(5, string.length() - 6);
auto parts = substring.split_view(',');
@ -252,10 +252,10 @@ Optional<Color> Color::from_string(StringView string)
return Color::from_rgb(web_colors[i].color);
}
if (string.starts_with("rgb("sv, CaseSensitivity::CaseInsensitive) && string.ends_with(")"))
if (string.starts_with("rgb("sv, CaseSensitivity::CaseInsensitive) && string.ends_with(')'))
return parse_rgb_color(string);
if (string.starts_with("rgba("sv, CaseSensitivity::CaseInsensitive) && string.ends_with(")"))
if (string.starts_with("rgba("sv, CaseSensitivity::CaseInsensitive) && string.ends_with(')'))
return parse_rgba_color(string);
if (string[0] != '#')

View file

@ -356,7 +356,7 @@ String BitmapFont::variant() const
if (builder.string_view() == "Regular"sv)
builder.clear();
else
builder.append(" ");
builder.append(' ');
builder.append(slope_to_name(slope()));
}
return builder.to_string();

View file

@ -231,7 +231,7 @@ String Path::to_string() const
builder.append(") "sv);
}
builder.append("}");
builder.append('}');
return builder.to_string();
}

View file

@ -303,7 +303,7 @@ RefPtr<Promise<Optional<SolidResponse>>> Client::store(StoreMethod method, Seque
StringBuilder flags_builder;
flags_builder.append('(');
flags_builder.join(" ", flags);
flags_builder.join(' ', flags);
flags_builder.append(')');
auto command = Command { uid ? CommandType::UIDStore : CommandType::Store, m_current_command, { sequence_set.serialize(), data_item_name.build(), flags_builder.build() } };
@ -361,7 +361,7 @@ RefPtr<Promise<Optional<SolidResponse>>> Client::status(StringView mailbox, Vect
}
StringBuilder types_list;
types_list.append('(');
types_list.join(" ", args);
types_list.join(' ', args);
types_list.append(')');
auto command = Command { CommandType::Status, m_current_command, { mailbox, types_list.build() } };
return cast_promise<SolidResponse>(send_command(move(command)));
@ -373,7 +373,7 @@ RefPtr<Promise<Optional<SolidResponse>>> Client::append(StringView mailbox, Mess
if (flags.has_value()) {
StringBuilder flags_sb;
flags_sb.append('(');
flags_sb.join(" ", flags.value());
flags_sb.join(' ', flags.value());
flags_sb.append(')');
args.append(flags_sb.build());
}

View file

@ -36,11 +36,11 @@ String FetchCommand::DataItem::Section::serialize() const
bool first = true;
for (auto& field : headers.value()) {
if (!first)
headers_builder.append(" ");
headers_builder.append(' ');
headers_builder.append(field);
first = false;
}
headers_builder.append(")");
headers_builder.append(')');
return headers_builder.build();
}
case SectionType::Text:
@ -50,7 +50,7 @@ String FetchCommand::DataItem::Section::serialize() const
bool first = true;
for (int part : parts.value()) {
if (!first)
sb.append(".");
sb.append('.');
sb.appendff("{}", part);
first = false;
}
@ -95,7 +95,7 @@ String FetchCommand::serialize()
bool first = true;
for (auto& sequence : sequence_set) {
if (!first) {
sequence_builder.append(",");
sequence_builder.append(',');
}
sequence_builder.append(sequence.serialize());
first = false;
@ -105,7 +105,7 @@ String FetchCommand::serialize()
first = true;
for (auto& data_item : data_items) {
if (!first) {
data_items_builder.append(" ");
data_items_builder.append(' ');
}
data_items_builder.append(data_item.serialize());
first = false;
@ -156,7 +156,7 @@ String SearchKey::serialize() const
[&](Recent const&) { return String("RECENT"); },
[&](SearchKeys const& x) {
StringBuilder sb;
sb.append("(");
sb.append('(');
bool first = true;
for (const auto& item : x.keys) {
if (!first)

View file

@ -1030,7 +1030,7 @@ String PushDeclarativeEnvironment::to_string_impl(Bytecode::Executable const& ex
Vector<String> names;
for (auto& it : m_variables)
names.append(executable.get_string(it.key));
builder.append("}");
builder.append('}');
builder.join(", "sv, names);
}
return builder.to_string();

View file

@ -791,7 +791,7 @@ JS_DEFINE_NATIVE_FUNCTION(StringPrototype::match_all)
auto flags = TRY(regexp.as_object().get("flags"));
auto flags_object = TRY(require_object_coercible(global_object, flags));
auto flags_string = TRY(flags_object.to_string(global_object));
if (!flags_string.contains("g"))
if (!flags_string.contains('g'))
return vm.throw_completion<TypeError>(global_object, ErrorType::StringNonGlobalRegExp);
}
if (auto* matcher = TRY(regexp.get_method(global_object, *vm.well_known_symbol_match_all())))
@ -885,7 +885,7 @@ JS_DEFINE_NATIVE_FUNCTION(StringPrototype::replace_all)
auto flags = TRY(search_value.as_object().get(vm.names.flags));
auto flags_object = TRY(require_object_coercible(global_object, flags));
auto flags_string = TRY(flags_object.to_string(global_object));
if (!flags_string.contains("g"))
if (!flags_string.contains('g'))
return vm.throw_completion<TypeError>(global_object, ErrorType::StringNonGlobalRegExp);
}

View file

@ -1718,7 +1718,7 @@ String Style::to_string() const
: "ReplaceEachCodePointInSelection");
}
builder.append("}");
builder.append('}');
return builder.build();
}

View file

@ -27,7 +27,7 @@ String List::render_to_html(bool) const
for (auto& item : m_items) {
builder.append("<li>"sv);
if (!m_is_tight || (item->blocks().size() != 0 && !dynamic_cast<Paragraph const*>(&(item->blocks()[0]))))
builder.append("\n");
builder.append('\n');
builder.append(item->render_to_html(m_is_tight));
builder.append("</li>\n"sv);
}
@ -47,7 +47,7 @@ String List::render_for_terminal(size_t) const
if (m_is_ordered)
builder.appendff("{}.", ++i);
else
builder.append("*");
builder.append('*');
builder.append(item->render_for_terminal());
}

View file

@ -42,10 +42,10 @@ String Table::render_for_terminal(size_t view_width) const
write_aligned(col.header, width, col.alignment);
}
builder.append("\n");
builder.append('\n');
for (size_t i = 0; i < view_width; ++i)
builder.append('-');
builder.append("\n");
builder.append('\n');
for (size_t i = 0; i < m_row_count; ++i) {
bool first = true;
@ -60,10 +60,10 @@ String Table::render_for_terminal(size_t view_width) const
size_t width = col.relative_width * unit_width_length;
write_aligned(cell, width, col.alignment);
}
builder.append("\n");
builder.append('\n');
}
builder.append("\n");
builder.append('\n');
return builder.to_string();
}

View file

@ -108,7 +108,7 @@ void Text::TextNode::render_to_html(StringBuilder& builder) const
void Text::TextNode::render_for_terminal(StringBuilder& builder) const
{
if (collapsible && (text == "\n" || text.is_whitespace())) {
builder.append(" ");
builder.append(' ');
} else {
builder.append(text);
}
@ -546,7 +546,7 @@ NonnullOwnPtr<Text::Node> Text::parse_code(Vector<Token>::ConstIterator& tokens)
if (!is_all_whitespace) {
auto& first = dynamic_cast<TextNode&>(code->children.first());
auto& last = dynamic_cast<TextNode&>(code->children.last());
if (first.text.starts_with(" ") && last.text.ends_with(" ")) {
if (first.text.starts_with(' ') && last.text.ends_with(' ')) {
first.text = first.text.substring(1);
last.text = last.text.substring(0, last.text.length() - 1);
}
@ -608,7 +608,7 @@ NonnullOwnPtr<Text::Node> Text::parse_strike_through(Vector<Token>::ConstIterato
if (!is_all_whitespace) {
auto& first = dynamic_cast<TextNode&>(striked_text->children.first());
auto& last = dynamic_cast<TextNode&>(striked_text->children.last());
if (first.text.starts_with(" ") && last.text.ends_with(" ")) {
if (first.text.starts_with(' ') && last.text.ends_with(' ')) {
first.text = first.text.substring(1);
last.text = last.text.substring(0, last.text.length() - 1);
}

View file

@ -172,7 +172,7 @@ struct Formatter<PDF::LineDashPattern> : Formatter<StringView> {
ErrorOr<void> format(FormatBuilder& format_builder, PDF::LineDashPattern const& pattern)
{
StringBuilder builder;
builder.append("[");
builder.append('[');
bool first = true;
for (auto& i : pattern.pattern) {
@ -248,7 +248,7 @@ struct Formatter<PDF::GraphicsState> : Formatter<StringView> {
builder.appendff(" miter_limit={}\n", state.miter_limit);
builder.appendff(" line_dash_pattern={}\n", state.line_dash_pattern);
builder.appendff(" text_state={}\n", state.text_state);
builder.append("}");
builder.append('}');
return format_builder.put_string(builder.to_string());
}
};

View file

@ -163,7 +163,7 @@ private:
bytes.append(String::formatted("{0:02x}", *(ptr + ix)));
}
StringBuilder bytes_builder;
bytes_builder.join(" ", bytes);
bytes_builder.join(' ', bytes);
builder.append(bytes_builder.to_string());
dbgln(builder.to_string());
}

View file

@ -380,7 +380,7 @@ void TreeNode::dump_if(int flag, String&& msg)
if (is_leaf()) {
builder.append(", leaf"sv);
}
builder.append(")");
builder.append(')');
dbgln(builder.build());
}

View file

@ -97,7 +97,7 @@ public:
for (auto& element : *this) {
elements.append(element.to_string());
}
return String::formatted("[\n{}\n]", String::join("\n", elements));
return String::formatted("[\n{}\n]", String::join('\n', elements));
}
using Vector<TupleElementDescriptor>::operator==;

View file

@ -874,11 +874,11 @@ Vector<String> ContainerValueImpl::to_string_vector() const
String ContainerValueImpl::to_string() const
{
StringBuilder builder;
builder.append("(");
builder.append('(');
StringBuilder joined;
joined.join(", "sv, to_string_vector());
builder.append(joined.string_view());
builder.append(")");
builder.append(')');
return builder.build();
}

View file

@ -1448,7 +1448,7 @@ void Terminal::unimplemented_csi_sequence(Parameters parameters, Intermediates i
builder.append(", parameters: ["sv);
for (size_t i = 0; i < parameters.size(); ++i)
builder.appendff("{}{}", (i == 0) ? "" : ", ", parameters[i]);
builder.append("]");
builder.append("]"sv);
}
if (!intermediates.is_empty()) {
builder.append(", intermediates:"sv);
@ -1469,7 +1469,7 @@ void Terminal::unimplemented_osc_sequence(OscParameters parameters, u8 last_byte
builder.append('[');
for (auto character : parameter)
builder.append((char)character);
builder.append("]");
builder.append(']');
first = false;
}

View file

@ -305,7 +305,7 @@ private:
break;
}
}
builder.append("]");
builder.append(']');
return { builder.to_string() };
}

View file

@ -22,7 +22,7 @@ String Block::to_string() const
StringBuilder builder;
builder.append(m_token.bracket_string());
builder.join(" ", m_values);
builder.join(' ', m_values);
builder.append(m_token.bracket_mirror_string());
return builder.to_string();

View file

@ -23,9 +23,9 @@ String Function::to_string() const
StringBuilder builder;
serialize_an_identifier(builder, m_name);
builder.append("(");
builder.join(" ", m_values);
builder.append(")");
builder.append('(');
builder.join(' ', m_values);
builder.append(')');
return builder.to_string();
}

View file

@ -2513,7 +2513,7 @@ Optional<StyleProperty> Parser::convert_to_style_property(Declaration const& dec
property_id = PropertyID::Custom;
} else if (has_ignored_vendor_prefix(property_name)) {
return {};
} else if (!property_name.starts_with("-")) {
} else if (!property_name.starts_with('-')) {
dbgln_if(CSS_PARSER_DEBUG, "Unrecognized CSS property '{}'", property_name);
return {};
}

View file

@ -25,11 +25,11 @@ String Rule::to_string() const
StringBuilder builder;
if (is_at_rule()) {
builder.append("@");
builder.append('@');
serialize_an_identifier(builder, m_at_rule_name);
}
builder.join(" ", m_prelude);
builder.join(' ', m_prelude);
if (m_block)
builder.append(m_block->to_string());

View file

@ -58,7 +58,7 @@ public:
// 3.
// - A is 1: Append "n" to result.
if (step_size == 1)
result.append("n");
result.append('n');
// - A is -1: Append "-n" to result.
else if (step_size == -1)
result.append("-n"sv);

View file

@ -72,7 +72,7 @@ Optional<StringView> extract_character_encoding_from_meta_element(String const&
return {};
if (lexer.consume_specific('"')) {
auto matching_double_quote = lexer.remaining().find("\"");
auto matching_double_quote = lexer.remaining().find('"');
if (!matching_double_quote.has_value())
return {};
@ -81,7 +81,7 @@ Optional<StringView> extract_character_encoding_from_meta_element(String const&
}
if (lexer.consume_specific('\'')) {
auto matching_single_quote = lexer.remaining().find("'");
auto matching_single_quote = lexer.remaining().find('\'');
if (!matching_single_quote.has_value())
return {};

View file

@ -53,7 +53,7 @@ JS::ThrowCompletionOr<JS::Value> WorkerDebugConsoleClient::printer(JS::Console::
return JS::js_undefined();
}
auto output = String::join(" ", arguments.get<JS::MarkedVector<JS::Value>>());
auto output = String::join(' ', arguments.get<JS::MarkedVector<JS::Value>>());
m_console.output_debug_message(log_level, output);
switch (log_level) {

View file

@ -85,7 +85,7 @@ public:
// 5. If origin's port is non-null, append a U+003A COLON character (:), and origin's port, serialized, to result.
if (port() != 0) {
result.append(":");
result.append(':');
result.append(String::number(port()));
}
// 6. Return result

View file

@ -27,12 +27,12 @@ String ConnectionInfo::resource_name() const
StringBuilder builder;
// "/" if the path component is empty
if (m_url.path().is_empty())
builder.append("/");
builder.append('/');
// The path component
builder.append(m_url.path());
// "?" if the query component is non-empty
if (!m_url.query().is_empty())
builder.append("?");
builder.append('?');
// the query component
builder.append(m_url.query());
return builder.to_string();

View file

@ -1641,35 +1641,35 @@ void Instruction::to_string_internal(StringBuilder& builder, u32 origin, SymbolP
case OP_RM8_imm8:
append_mnemonic_space();
append_rm8();
append(",");
append(',');
append_imm8();
break;
case OP_RM16_imm8:
append_mnemonic_space();
append_rm16();
append(",");
append(',');
append_imm8();
break;
case OP_RM32_imm8:
append_mnemonic_space();
append_rm32();
append(",");
append(',');
append_imm8();
break;
case OP_reg16_RM16_imm8:
append_mnemonic_space();
append_reg16();
append(",");
append(',');
append_rm16();
append(",");
append(',');
append_imm8();
break;
case OP_reg32_RM32_imm8:
append_mnemonic_space();
append_reg32();
append(",");
append(',');
append_rm32();
append(",");
append(',');
append_imm8();
break;
case OP_AL_imm8:
@ -1724,23 +1724,23 @@ void Instruction::to_string_internal(StringBuilder& builder, u32 origin, SymbolP
case OP_reg16_imm16:
append_mnemonic_space();
append_reg16();
append(",");
append(',');
append_imm16();
break;
case OP_reg16_RM16_imm16:
append_mnemonic_space();
append_reg16();
append(",");
append(',');
append_rm16();
append(",");
append(',');
append_imm16();
break;
case OP_reg32_RM32_imm32:
append_mnemonic_space();
append_reg32();
append(",");
append(',');
append_rm32();
append(",");
append(',');
append_imm32();
break;
case OP_imm32:
@ -1960,142 +1960,142 @@ void Instruction::to_string_internal(StringBuilder& builder, u32 origin, SymbolP
case OP_RM8_reg8:
append_mnemonic_space();
append_rm8();
append(",");
append(',');
append_reg8();
break;
case OP_RM16_reg16:
append_mnemonic_space();
append_rm16();
append(",");
append(',');
append_reg16();
break;
case OP_RM32_reg32:
append_mnemonic_space();
append_rm32();
append(",");
append(',');
append_reg32();
break;
case OP_reg8_RM8:
append_mnemonic_space();
append_reg8();
append(",");
append(',');
append_rm8();
break;
case OP_reg16_RM16:
append_mnemonic_space();
append_reg16();
append(",");
append(',');
append_rm16();
break;
case OP_reg32_RM32:
append_mnemonic_space();
append_reg32();
append(",");
append(',');
append_rm32();
break;
case OP_reg32_RM16:
append_mnemonic_space();
append_reg32();
append(",");
append(',');
append_rm16();
break;
case OP_reg16_RM8:
append_mnemonic_space();
append_reg16();
append(",");
append(',');
append_rm8();
break;
case OP_reg32_RM8:
append_mnemonic_space();
append_reg32();
append(",");
append(',');
append_rm8();
break;
case OP_RM16_imm16:
append_mnemonic_space();
append_rm16();
append(",");
append(',');
append_imm16();
break;
case OP_RM32_imm32:
append_mnemonic_space();
append_rm32();
append(",");
append(',');
append_imm32();
break;
case OP_RM16_seg:
append_mnemonic_space();
append_rm16();
append(",");
append(',');
append_seg();
break;
case OP_RM32_seg:
append_mnemonic_space();
append_rm32();
append(",");
append(',');
append_seg();
break;
case OP_seg_RM16:
append_mnemonic_space();
append_seg();
append(",");
append(',');
append_rm16();
break;
case OP_seg_RM32:
append_mnemonic_space();
append_seg();
append(",");
append(',');
append_rm32();
break;
case OP_reg16_mem16:
append_mnemonic_space();
append_reg16();
append(",");
append(',');
append_rm16();
break;
case OP_reg32_mem32:
append_mnemonic_space();
append_reg32();
append(",");
append(',');
append_rm32();
break;
case OP_FAR_mem16:
append_mnemonic_space();
append("far ");
append("far "sv);
append_rm16();
break;
case OP_FAR_mem32:
append_mnemonic_space();
append("far ");
append("far "sv);
append_rm32();
break;
case OP_reg32_CR:
append_mnemonic_space();
builder.append(register_name(static_cast<RegisterIndex32>(modrm().rm())));
append(",");
append(',');
append_creg();
break;
case OP_CR_reg32:
append_mnemonic_space();
append_creg();
append(",");
append(',');
builder.append(register_name(static_cast<RegisterIndex32>(modrm().rm())));
break;
case OP_reg32_DR:
append_mnemonic_space();
builder.append(register_name(static_cast<RegisterIndex32>(modrm().rm())));
append(",");
append(',');
append_dreg();
break;
case OP_DR_reg32:
append_mnemonic_space();
append_dreg();
append(",");
append(',');
builder.append(register_name(static_cast<RegisterIndex32>(modrm().rm())));
break;
case OP_short_imm8:
append_mnemonic_space();
append("short ");
append("short "sv);
append_relative_imm8();
break;
case OP_relimm16:
@ -2108,38 +2108,38 @@ void Instruction::to_string_internal(StringBuilder& builder, u32 origin, SymbolP
break;
case OP_NEAR_imm:
append_mnemonic_space();
append("near ");
append("near "sv);
append_relative_addr();
break;
case OP_RM16_reg16_imm8:
append_mnemonic_space();
append_rm16();
append(",");
append(',');
append_reg16();
append(",");
append(',');
append_imm8();
break;
case OP_RM32_reg32_imm8:
append_mnemonic_space();
append_rm32();
append(",");
append(',');
append_reg32();
append(",");
append(',');
append_imm8();
break;
case OP_RM16_reg16_CL:
append_mnemonic_space();
append_rm16();
append(",");
append(',');
append_reg16();
append(", cl");
append(", cl"sv);
break;
case OP_RM32_reg32_CL:
append_mnemonic_space();
append_rm32();
append(",");
append(',');
append_reg32();
append(",cl");
append(",cl"sv);
break;
case OP_reg:
append_mnemonic_space();
@ -2155,66 +2155,66 @@ void Instruction::to_string_internal(StringBuilder& builder, u32 origin, SymbolP
case OP_mm1_imm8:
append_mnemonic_space();
append_mm_or_xmm();
append(",");
append(',');
append_imm8();
break;
case OP_mm1_mm2m32:
append_mnemonic_space();
append_mm_or_xmm();
append(",");
append(',');
append_mm_or_xmm_or_mem();
break;
case OP_mm1_rm32:
append_mnemonic_space();
append_mm_or_xmm();
append(",");
append(',');
append_rm32();
break;
case OP_rm32_mm2:
append_mnemonic_space();
append_rm32();
append(",");
append(',');
append_mm_or_xmm();
break;
case OP_mm1_mm2m64:
append_mnemonic_space();
append_mm_or_xmm();
append(",");
append(',');
append_mm_or_xmm_or_mem();
break;
case OP_mm1m64_mm2:
append_mnemonic_space();
append_mm_or_xmm_or_mem();
append(",");
append(',');
append_mm_or_xmm();
break;
case OP_mm1_mm2m64_imm8:
append_mnemonic_space();
append_mm_or_xmm();
append(",");
append(',');
append_mm_or_xmm_or_mem();
append(",");
append(',');
append_imm8();
break;
case OP_reg_mm1:
append_mnemonic_space();
append_rm32();
append(",");
append(',');
append_mm_or_xmm();
break;
case OP_reg_mm1_imm8:
append_mnemonic_space();
append_reg32();
append(",");
append(',');
append_mm_or_xmm_or_mem();
append(",");
append(',');
append_imm8();
break;
case OP_mm1_r32m16_imm8:
append_mnemonic_space();
append_mm_or_xmm();
append_rm32(); // FIXME: r32m16
append(",");
append(',');
append_imm8();
break;
case __SSE:
@ -2222,150 +2222,150 @@ void Instruction::to_string_internal(StringBuilder& builder, u32 origin, SymbolP
case OP_xmm_mm:
append_mnemonic_space();
append_xmm();
append(",");
append(',');
append_mmrm32(); // FIXME: No Memmory
break;
case OP_mm1_xmm2m128:
case OP_mm_xmm:
append_mnemonic_space();
append_mm();
append(",");
append(',');
append_xmmrm32(); // FIXME: No Memmory
break;
case OP_xmm1_imm8:
append_mnemonic_space();
append_xmm();
append(",");
append(',');
append_imm8();
break;
case OP_xmm1_xmm2m32:
append_mnemonic_space();
append_xmm();
append(",");
append(',');
append_xmmrm32();
break;
case OP_xmm1_xmm2m64:
append_mnemonic_space();
append_xmm();
append(",");
append(',');
append_xmmrm64();
break;
case OP_xmm1_xmm2m128:
append_mnemonic_space();
append_xmm();
append(",");
append(',');
append_xmmrm128();
break;
case OP_xmm1_xmm2m32_imm8:
append_mnemonic_space();
append_xmm();
append(",");
append(',');
append_xmmrm32();
append(",");
append(',');
append_imm8();
break;
case OP_xmm1_xmm2m128_imm8:
append_mnemonic_space();
append_xmm();
append(",");
append(',');
append_xmmrm32();
append(",");
append(',');
append_imm8();
break;
case OP_xmm1m32_xmm2:
append_mnemonic_space();
append_xmmrm32();
append(",");
append(',');
append_xmm();
break;
case OP_xmm1m64_xmm2:
append_mnemonic_space();
append_xmmrm64();
append(",");
append(',');
append_xmm();
break;
case OP_xmm1m128_xmm2:
append_mnemonic_space();
append_xmmrm128();
append(",");
append(',');
append_xmm();
break;
case OP_reg_xmm1:
case OP_r32_xmm2m64:
append_mnemonic_space();
append_reg32();
append(",");
append(',');
append_xmmrm128(); // second entry in the rm byte
break;
case OP_rm32_xmm2:
append_mnemonic_space();
append_rm32();
append(",");
append(',');
append_xmm();
break;
case OP_reg_xmm1_imm8:
append_mnemonic_space();
append_reg32();
append(",");
append(',');
append_xmmrm128(); // second entry in the rm byte
append(",");
append(',');
append_imm8();
break;
case OP_xmm1_rm32:
append_mnemonic_space();
append_xmm();
append(",");
append(',');
append_rm32(); // second entry in the rm byte
break;
case OP_xmm1_m64:
append_mnemonic_space();
append_xmm();
append(",");
append(',');
append_rm64(); // second entry in the rm byte
break;
case OP_m64_xmm2:
append_mnemonic_space();
append_rm64(); // second entry in the rm byte
append(",");
append(',');
append_xmm();
break;
case OP_rm8_xmm2m32:
append_mnemonic_space();
append_rm8();
append(",");
append(',');
append_xmmrm32();
break;
case OP_xmm1_mm2m64:
append_mnemonic_space();
append_xmm();
append(",");
append(',');
append_mmrm64();
break;
case OP_mm1m64_xmm2:
append_mnemonic_space();
append_mmrm64();
append(",");
append(',');
append_xmm();
break;
case OP_mm1_xmm2m64:
append_mnemonic_space();
append_mm();
append(",");
append(',');
append_xmmrm64();
break;
case OP_r32_xmm2m32:
append_mnemonic_space();
append_reg32();
append(",");
append(',');
append_xmmrm32();
break;
case OP_xmm1_r32m16_imm8:
append_mnemonic_space();
append_xmm();
append(",");
append(',');
append_rm32(); // FIXME: r32m16
append(",");
append(',');
append_imm8();
break;
case InstructionPrefix:

View file

@ -355,7 +355,7 @@ String deduplicate_destination_file_name(String const& destination)
StringBuilder basename;
basename.appendff("{}-{}", title_without_counter, next_counter);
if (!destination_path.extension().is_empty()) {
basename.append(".");
basename.append('.');
basename.append(destination_path.extension());
}

View file

@ -112,7 +112,7 @@ QuickLaunchWidget::QuickLaunchWidget()
OwnPtr<QuickLaunchEntry> QuickLaunchEntry::create_from_config_value(StringView value)
{
if (!value.starts_with("/") && value.ends_with(".af"sv)) {
if (!value.starts_with('/') && value.ends_with(".af"sv)) {
auto af_path = String::formatted("{}/{}", Desktop::AppFile::APP_FILES_DIRECTORY, value);
return make<QuickLaunchEntryAppFile>(Desktop::AppFile::open(af_path));
}

View file

@ -130,7 +130,7 @@ ErrorOr<bool> Client::handle_request(ReadonlyBytes raw_request)
if (Core::File::is_directory(real_path)) {
if (!request.resource().ends_with("/")) {
if (!request.resource().ends_with('/')) {
StringBuilder red;
red.append(requested_path);

View file

@ -2665,7 +2665,7 @@ RefPtr<Value> ReadRedirection::run(RefPtr<Shell> shell)
return make_ref_counted<ListValue>({});
StringBuilder builder;
builder.join(" ", path_segments);
builder.join(' ', path_segments);
command.redirections.append(PathRedirection::create(builder.to_string(), m_fd, PathRedirection::Read));
return make_ref_counted<CommandValue>(move(command));
@ -2695,7 +2695,7 @@ RefPtr<Value> ReadWriteRedirection::run(RefPtr<Shell> shell)
return make_ref_counted<ListValue>({});
StringBuilder builder;
builder.join(" ", path_segments);
builder.join(' ', path_segments);
command.redirections.append(PathRedirection::create(builder.to_string(), m_fd, PathRedirection::ReadWrite));
return make_ref_counted<CommandValue>(move(command));
@ -3052,7 +3052,7 @@ void Juxtaposition::highlight_in_editor(Line::Editor& editor, Shell& shell, High
StringBuilder path_builder;
path_builder.append(tilde_value);
path_builder.append("/");
path_builder.append('/');
path_builder.append(bareword_value);
auto path = path_builder.to_string();
@ -3183,8 +3183,8 @@ RefPtr<Value> StringPartCompose::run(RefPtr<Shell> shell)
return make_ref_counted<ListValue>({});
StringBuilder builder;
builder.join(" ", left);
builder.join(" ", right);
builder.join(' ', left);
builder.join(' ', right);
return make_ref_counted<StringValue>(builder.to_string());
}
@ -3347,7 +3347,7 @@ RefPtr<Value> WriteAppendRedirection::run(RefPtr<Shell> shell)
return make_ref_counted<ListValue>({});
StringBuilder builder;
builder.join(" ", path_segments);
builder.join(' ', path_segments);
command.redirections.append(PathRedirection::create(builder.to_string(), m_fd, PathRedirection::WriteAppend));
return make_ref_counted<CommandValue>(move(command));
@ -3377,7 +3377,7 @@ RefPtr<Value> WriteRedirection::run(RefPtr<Shell> shell)
return make_ref_counted<ListValue>({});
StringBuilder builder;
builder.join(" ", path_segments);
builder.join(' ', path_segments);
command.redirections.append(PathRedirection::create(builder.to_string(), m_fd, PathRedirection::Write));
return make_ref_counted<CommandValue>(move(command));
@ -3724,7 +3724,7 @@ String TildeValue::resolve_as_string(RefPtr<Shell> shell)
Vector<String> TildeValue::resolve_as_list(RefPtr<Shell> shell)
{
StringBuilder builder;
builder.append("~");
builder.append('~');
builder.append(m_username);
if (!shell)

View file

@ -207,11 +207,11 @@ int Shell::builtin_type(int argc, char const** argv)
if (!dont_show_function_source) {
StringBuilder builder;
builder.append(fn.name);
builder.append("(");
builder.append('(');
for (size_t i = 0; i < fn.arguments.size(); i++) {
builder.append(fn.arguments[i]);
if (!(i == fn.arguments.size() - 1))
builder.append(" ");
builder.append(' ');
}
builder.append(") {\n"sv);
if (fn.body) {
@ -448,7 +448,7 @@ int Shell::builtin_export(int argc, char const** argv)
if (value) {
auto values = value->resolve_as_list(*this);
StringBuilder builder;
builder.join(" ", values);
builder.join(' ', values);
parts.append(builder.to_string());
} else {
// Ignore the export.

View file

@ -41,7 +41,7 @@ String Formatter::format()
auto string = current_builder().string_view();
if (!string.ends_with(" "))
if (!string.ends_with(' '))
current_builder().append(m_trivia);
return current_builder().to_string();

View file

@ -1969,7 +1969,7 @@ RefPtr<AST::Node> Parser::parse_glob()
textbuilder.append(bareword->text());
} else if (glob_after->is_tilde()) {
auto bareword = static_cast<AST::Tilde*>(glob_after.ptr());
textbuilder.append("~");
textbuilder.append('~');
textbuilder.append(bareword->text());
} else {
return create<AST::SyntaxError>(String::formatted("Invalid node '{}' in glob position, escape shell special characters", glob_after->class_name()));

View file

@ -390,7 +390,7 @@ String Shell::local_variable_or(StringView name, String const& replacement) cons
auto value = lookup_local_variable(name);
if (value) {
StringBuilder builder;
builder.join(" ", value->resolve_as_list(*this));
builder.join(' ', value->resolve_as_list(*this));
return builder.to_string();
}
return replacement;
@ -839,7 +839,7 @@ ErrorOr<RefPtr<Job>> Shell::run_command(const AST::Command& command)
close(sync_pipe[1]);
StringBuilder cmd;
cmd.join(" ", command.argv);
cmd.join(' ', command.argv);
auto command_copy = AST::Command(command);
// Clear the next chain if it's to be immediately executed

View file

@ -128,7 +128,7 @@ private:
span.attributes.color = m_palette.syntax_keyword();
span.attributes.bold = true;
m_is_first_in_command = false;
} else if (node->text().starts_with("-")) {
} else if (node->text().starts_with('-')) {
span.attributes.color = m_palette.syntax_preprocessor_statement();
} else {
span.attributes.color = m_palette.base_text();

View file

@ -34,7 +34,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
if (definition.value.parameters.is_empty())
outln("{}: {}", definition.key, definition.value.value);
else
outln("{}({}): {}", definition.key, String::join(",", definition.value.parameters), definition.value.value);
outln("{}({}): {}", definition.key, String::join(',', definition.value.parameters), definition.value.value);
}
outln("");
}

View file

@ -41,11 +41,11 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
// Action
if (num_added > 0 && num_removed > 0)
sb.append("c");
sb.append('c');
else if (num_added > 0)
sb.append("a");
sb.append('a');
else
sb.append("d");
sb.append('d');
// Target line(s)
sb.appendff("{}", target_start);

View file

@ -1449,7 +1449,7 @@ public:
return JS::js_undefined();
}
auto output = String::join(" ", arguments.get<JS::MarkedVector<JS::Value>>());
auto output = String::join(' ', arguments.get<JS::MarkedVector<JS::Value>>());
m_console.output_debug_message(log_level, output);
switch (log_level) {

View file

@ -54,7 +54,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
}
StringBuilder path_builder;
if (lexical_path.is_absolute())
path_builder.append("/");
path_builder.append('/');
auto& parts = lexical_path.parts_view();
size_t num_parts = parts.size();
@ -88,7 +88,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
break;
}
}
path_builder.append("/");
path_builder.append('/');
}
}
return has_errors ? 1 : 0;

View file

@ -70,7 +70,7 @@ static int get_source_fd(StringView source)
static bool mount_by_line(String const& line)
{
// Skip comments and blank lines.
if (line.is_empty() || line.starts_with("#"))
if (line.is_empty() || line.starts_with('#'))
return true;
Vector<String> parts = line.split('\t');

View file

@ -205,7 +205,7 @@ void print_human_readable(termios const& modes, winsize const& ws, bool verbose_
auto escape_character = [&](u8 ch) {
StringBuilder sb;
if (ch <= 0x20) {
sb.append("^");
sb.append('^');
sb.append(ch + 0x40);
} else if (ch == 0x7f) {
sb.append("^?"sv);

View file

@ -93,7 +93,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
if (line.is_empty())
continue;
if (line.starts_with(".")) {
if (line.starts_with('.')) {
if (line.starts_with(".text "sv)) {
editor->add_to_history(line);
if (socket->ready_state() != Protocol::WebSocket::ReadyState::Open) {

View file

@ -197,7 +197,7 @@ bool run_command(Vector<char*>&& child_argv, bool verbose, bool is_stdin, int de
if (verbose) {
StringBuilder builder;
builder.join(" ", child_argv);
builder.join(' ', child_argv);
warnln("xargs: {}", builder.to_string());
}

View file

@ -424,10 +424,10 @@ static void do_run_tests(XML::Document& document)
StringBuilder path_builder;
path_builder.append(base_path);
path_builder.append("/");
path_builder.append('/');
for (auto& entry : bases.in_reverse()) {
path_builder.append(entry);
path_builder.append("/");
path_builder.append('/');
}
auto test_base_path = path_builder.to_string();