1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 21:27:45 +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

@ -125,8 +125,8 @@ public:
virtual bool is_function() const { return false; }
virtual bool is_namespace() const { return false; }
virtual bool is_member() const { return false; }
const StringView& name() const { return m_name; }
void set_name(const StringView& name) { m_name = move(name); }
StringView name() const { return m_name; }
void set_name(StringView name) { m_name = move(name); }
protected:
Declaration(ASTNode* parent, Optional<Position> start, Optional<Position> end, const String& filename)
@ -417,7 +417,7 @@ public:
virtual bool is_identifier() const override { return true; }
StringView const& name() const { return m_name; }
StringView name() const { return m_name; }
void set_name(StringView&& name) { m_name = move(name); }
private:

View file

@ -13,7 +13,7 @@
namespace Cpp {
Lexer::Lexer(StringView const& input, size_t start_line)
Lexer::Lexer(StringView input, size_t start_line)
: m_input(input)
, m_previous_position { start_line, 0 }
, m_position { start_line, 0 }
@ -188,7 +188,7 @@ constexpr char const* s_known_types[] = {
"wchar_t"
};
static bool is_keyword(StringView const& string)
static bool is_keyword(StringView string)
{
static HashTable<String> keywords(array_size(s_known_keywords));
if (keywords.is_empty()) {
@ -197,7 +197,7 @@ static bool is_keyword(StringView const& string)
return keywords.contains(string);
}
static bool is_known_type(StringView const& string)
static bool is_known_type(StringView string)
{
static HashTable<String> types(array_size(s_known_types));
if (types.is_empty()) {

View file

@ -14,7 +14,7 @@ namespace Cpp {
class Lexer {
public:
explicit Lexer(StringView const&, size_t start_line = 0);
explicit Lexer(StringView, size_t start_line = 0);
Vector<Token> lex();
template<typename Callback>

View file

@ -628,7 +628,7 @@ Optional<Parser::DeclarationType> Parser::match_declaration_in_translation_unit(
return {};
}
Optional<Parser::DeclarationType> Parser::match_class_member(const StringView& class_name)
Optional<Parser::DeclarationType> Parser::match_class_member(StringView class_name)
{
if (match_function_declaration())
return DeclarationType::Function;
@ -1557,7 +1557,7 @@ NonnullRefPtr<BracedInitList> Parser::parse_braced_init_list(ASTNode& parent)
}
NonnullRefPtrVector<Declaration> Parser::parse_class_members(StructOrClassDeclaration& parent)
{
auto& class_name = parent.name();
auto class_name = parent.name();
NonnullRefPtrVector<Declaration> members;
while (!eof() && peek().type() != Token::Type::RightCurly) {
@ -1588,7 +1588,7 @@ void Parser::consume_access_specifier()
consume(Token::Type::Colon);
}
bool Parser::match_constructor(const StringView& class_name)
bool Parser::match_constructor(StringView class_name)
{
save_state();
ScopeGuard state_guard = [this] { load_state(); };
@ -1606,7 +1606,7 @@ bool Parser::match_constructor(const StringView& class_name)
return (peek(Token::Type::Semicolon).has_value() || peek(Token::Type::LeftCurly).has_value());
}
bool Parser::match_destructor(const StringView& class_name)
bool Parser::match_destructor(StringView class_name)
{
save_state();
ScopeGuard state_guard = [this] { load_state(); };

View file

@ -56,7 +56,7 @@ private:
};
Optional<DeclarationType> match_declaration_in_translation_unit();
Optional<Parser::DeclarationType> match_class_member(const StringView& class_name);
Optional<Parser::DeclarationType> match_class_member(StringView class_name);
bool match_function_declaration();
bool match_comment();
@ -82,8 +82,8 @@ private:
bool match_type();
bool match_named_type();
bool match_access_specifier();
bool match_constructor(const StringView& class_name);
bool match_destructor(const StringView& class_name);
bool match_constructor(StringView class_name);
bool match_destructor(StringView class_name);
Optional<NonnullRefPtrVector<Parameter>> parse_parameter_list(ASTNode& parent);
Optional<Token> consume_whitespace();

View file

@ -12,7 +12,7 @@
#include <ctype.h>
namespace Cpp {
Preprocessor::Preprocessor(const String& filename, const StringView& program)
Preprocessor::Preprocessor(const String& filename, StringView program)
: m_filename(filename)
, m_program(program)
{
@ -86,7 +86,7 @@ static void consume_whitespace(GenericLexer& lexer)
}
}
void Preprocessor::handle_preprocessor_statement(StringView const& line)
void Preprocessor::handle_preprocessor_statement(StringView line)
{
GenericLexer lexer(line);
@ -100,7 +100,7 @@ void Preprocessor::handle_preprocessor_statement(StringView const& line)
handle_preprocessor_keyword(keyword, lexer);
}
void Preprocessor::handle_include_statement(StringView const& include_path)
void Preprocessor::handle_include_statement(StringView include_path)
{
m_included_paths.append(include_path);
if (definitions_in_header_callback) {
@ -109,7 +109,7 @@ void Preprocessor::handle_include_statement(StringView const& include_path)
}
}
void Preprocessor::handle_preprocessor_keyword(const StringView& keyword, GenericLexer& line_lexer)
void Preprocessor::handle_preprocessor_keyword(StringView keyword, GenericLexer& line_lexer)
{
if (keyword == "include") {
// Should have called 'handle_include_statement'.
@ -345,7 +345,7 @@ Optional<Preprocessor::Definition> Preprocessor::create_definition(StringView li
return definition;
}
String Preprocessor::remove_escaped_newlines(StringView const& value)
String Preprocessor::remove_escaped_newlines(StringView value)
{
AK::StringBuilder processed_value;
GenericLexer lexer { value };

View file

@ -20,7 +20,7 @@ namespace Cpp {
class Preprocessor {
public:
explicit Preprocessor(const String& filename, const StringView& program);
explicit Preprocessor(const String& filename, StringView program);
Vector<Token> process_and_lex();
Vector<StringView> included_paths() const { return m_included_paths; }
@ -49,10 +49,10 @@ public:
Function<Definitions(StringView)> definitions_in_header_callback { nullptr };
private:
void handle_preprocessor_statement(StringView const&);
void handle_include_statement(StringView const&);
void handle_preprocessor_keyword(StringView const& keyword, GenericLexer& line_lexer);
String remove_escaped_newlines(StringView const& value);
void handle_preprocessor_statement(StringView);
void handle_include_statement(StringView);
void handle_preprocessor_keyword(StringView keyword, GenericLexer& line_lexer);
String remove_escaped_newlines(StringView value);
size_t do_substitution(Vector<Token> const& tokens, size_t token_index, Definition const&);
Optional<Definition> create_definition(StringView line);

View file

@ -96,7 +96,7 @@ struct Token {
#undef __TOKEN
};
Token(Type type, const Position& start, const Position& end, const StringView& text)
Token(Type type, const Position& start, const Position& end, StringView text)
: m_type(type)
, m_start(start)
, m_end(end)
@ -125,7 +125,7 @@ struct Token {
void set_start(const Position& other) { m_start = other; }
void set_end(const Position& other) { m_end = other; }
Type type() const { return m_type; }
const StringView& text() const { return m_text; }
StringView text() const { return m_text; }
private:
Type m_type { Type::Unknown };