1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 17:47:36 +00:00

Everywhere: Pass AK::StringView by value

This commit is contained in:
Andreas Kling 2021-11-11 00:55:02 +01:00
parent ad5d217e76
commit 8b1108e485
392 changed files with 978 additions and 978 deletions

View file

@ -1145,7 +1145,7 @@ bool Shell::run_builtin(const AST::Command& command, const NonnullRefPtrVector<A
return false;
}
bool Shell::has_builtin(const StringView& name) const
bool Shell::has_builtin(StringView name) const
{
#define __ENUMERATE_SHELL_BUILTIN(builtin) \
if (name == #builtin) { \

View file

@ -19,7 +19,7 @@ namespace Shell {
class Formatter final : public AST::NodeVisitor {
public:
Formatter(const StringView& source, ssize_t cursor = -1)
Formatter(StringView source, ssize_t cursor = -1)
: m_builders({ StringBuilder { round_up_to_power_of_two(source.length(), 16) } })
, m_source(source)
, m_cursor(cursor)

View file

@ -396,7 +396,7 @@ RefPtr<AST::Node> Shell::run_immediate_function(StringView str, AST::ImmediateEx
return nullptr;
}
bool Shell::has_immediate_function(const StringView& str)
bool Shell::has_immediate_function(StringView str)
{
#define __ENUMERATE_SHELL_IMMEDIATE_FUNCTION(name) \
if (str == #name) \

View file

@ -63,7 +63,7 @@ bool Parser::expect(char ch)
return expect(StringView { &ch, 1 });
}
bool Parser::expect(const StringView& expected)
bool Parser::expect(StringView expected)
{
auto offset_at_start = m_offset;
auto line_at_start = line();
@ -2130,7 +2130,7 @@ StringView Parser::consume_while(Function<bool(char)> condition)
return m_input.substring_view(start_offset, m_offset - start_offset);
}
bool Parser::next_is(const StringView& next)
bool Parser::next_is(StringView next)
{
auto start = current_position();
auto res = expect(next);

View file

@ -110,8 +110,8 @@ private:
char peek();
char consume();
bool expect(char);
bool expect(const StringView&);
bool next_is(const StringView&);
bool expect(StringView);
bool next_is(StringView);
void restore_to(size_t offset, AST::Position::Line line)
{

View file

@ -168,7 +168,7 @@ String Shell::expand_tilde(const String& expression)
return String::formatted("{}/{}", passwd->pw_dir, path.to_string());
}
bool Shell::is_glob(const StringView& s)
bool Shell::is_glob(StringView s)
{
for (size_t i = 0; i < s.length(); i++) {
char c = s.characters_without_null_termination()[i];
@ -178,7 +178,7 @@ bool Shell::is_glob(const StringView& s)
return false;
}
Vector<StringView> Shell::split_path(const StringView& path)
Vector<StringView> Shell::split_path(StringView path)
{
Vector<StringView> parts;
@ -200,7 +200,7 @@ Vector<StringView> Shell::split_path(const StringView& path)
return parts;
}
Vector<String> Shell::expand_globs(const StringView& path, StringView base)
Vector<String> Shell::expand_globs(StringView path, StringView base)
{
auto explicitly_set_base = false;
if (path.starts_with('/')) {
@ -238,7 +238,7 @@ Vector<String> Shell::expand_globs(const StringView& path, StringView base)
return results;
}
Vector<String> Shell::expand_globs(Vector<StringView> path_segments, const StringView& base)
Vector<String> Shell::expand_globs(Vector<StringView> path_segments, StringView base)
{
if (path_segments.is_empty()) {
String base_str = base;
@ -472,7 +472,7 @@ bool Shell::invoke_function(const AST::Command& command, int& retval)
return true;
}
String Shell::format(const StringView& source, ssize_t& cursor) const
String Shell::format(StringView source, ssize_t& cursor) const
{
Formatter formatter(source, cursor);
auto result = formatter.format();
@ -513,7 +513,7 @@ String Shell::resolve_alias(const String& name) const
return m_aliases.get(name).value_or({});
}
bool Shell::is_runnable(const StringView& name)
bool Shell::is_runnable(StringView name)
{
auto parts = name.split_view('/');
auto path = name.to_string();
@ -527,7 +527,7 @@ bool Shell::is_runnable(const StringView& name)
[](auto& name, auto& program) { return strcmp(name.characters(), program.characters()); });
}
int Shell::run_command(const StringView& cmd, Optional<SourcePosition> source_position_override)
int Shell::run_command(StringView cmd, Optional<SourcePosition> source_position_override)
{
// The default-constructed mode of the shell
// should not be used for execution!
@ -1277,7 +1277,7 @@ String Shell::unescape_token(const String& token)
return builder.build();
}
String Shell::find_in_path(const StringView& program_name)
String Shell::find_in_path(StringView program_name)
{
String path = getenv("PATH");
if (!path.is_empty()) {
@ -1593,7 +1593,7 @@ Vector<Line::CompletionSuggestion> Shell::complete_option(const String& program_
negate = true;
option_pattern = option_pattern.substring_view(3, option_pattern.length() - 3);
}
auto maybe_negate = [&](const StringView& view) {
auto maybe_negate = [&](StringView view) {
static StringBuilder builder;
builder.clear();
builder.append("--");

View file

@ -85,27 +85,27 @@ public:
Optional<AST::Position> position;
};
int run_command(const StringView&, Optional<SourcePosition> = {});
bool is_runnable(const StringView&);
int run_command(StringView, Optional<SourcePosition> = {});
bool is_runnable(StringView);
RefPtr<Job> run_command(const AST::Command&);
NonnullRefPtrVector<Job> run_commands(Vector<AST::Command>&);
bool run_file(const String&, bool explicitly_invoked = true);
bool run_builtin(const AST::Command&, const NonnullRefPtrVector<AST::Rewiring>&, int& retval);
bool has_builtin(const StringView&) const;
bool has_builtin(StringView) const;
RefPtr<AST::Node> run_immediate_function(StringView name, AST::ImmediateExpression& invoking_node, const NonnullRefPtrVector<AST::Node>&);
static bool has_immediate_function(const StringView&);
static bool has_immediate_function(StringView);
void block_on_job(RefPtr<Job>);
void block_on_pipeline(RefPtr<AST::Pipeline>);
String prompt() const;
static String expand_tilde(const String&);
static Vector<String> expand_globs(const StringView& path, StringView base);
static Vector<String> expand_globs(Vector<StringView> path_segments, const StringView& base);
static Vector<String> expand_globs(StringView path, StringView base);
static Vector<String> expand_globs(Vector<StringView> path_segments, StringView base);
Vector<AST::Command> expand_aliases(Vector<AST::Command>);
String resolve_path(String) const;
String resolve_alias(const String&) const;
static String find_in_path(const StringView& program_name);
static String find_in_path(StringView program_name);
static bool has_history_event(StringView);
@ -119,7 +119,7 @@ public:
bool has_function(const String&);
bool invoke_function(const AST::Command&, int& retval);
String format(const StringView&, ssize_t& cursor) const;
String format(StringView, ssize_t& cursor) const;
RefPtr<Line::Editor> editor() const { return m_editor; }
@ -165,8 +165,8 @@ public:
};
static SpecialCharacterEscapeMode special_character_escape_mode(u32 c);
static bool is_glob(const StringView&);
static Vector<StringView> split_path(const StringView&);
static bool is_glob(StringView);
static Vector<StringView> split_path(StringView);
enum class ExecutableOnly {
Yes,