1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-26 22:47:45 +00:00

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

@ -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();
}