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

@ -20,7 +20,7 @@
namespace Audio {
FlacLoaderPlugin::FlacLoaderPlugin(const StringView& path)
FlacLoaderPlugin::FlacLoaderPlugin(StringView path)
: m_file(Core::File::construct(path))
{
if (!m_file->open(Core::OpenMode::ReadOnly)) {

View file

@ -69,7 +69,7 @@ ALWAYS_INLINE i32 decode_unsigned_exp_golomb(u8 order, InputBitStream& bit_input
class FlacLoaderPlugin : public LoaderPlugin {
public:
FlacLoaderPlugin(const StringView& path);
FlacLoaderPlugin(StringView path);
FlacLoaderPlugin(const ByteBuffer& buffer);
~FlacLoaderPlugin()
{

View file

@ -9,7 +9,7 @@
namespace Audio {
Loader::Loader(const StringView& path)
Loader::Loader(StringView path)
{
m_plugin = make<WavLoaderPlugin>(path);
if (m_plugin->sniff())

View file

@ -51,7 +51,7 @@ public:
class Loader : public RefCounted<Loader> {
public:
static NonnullRefPtr<Loader> create(const StringView& path) { return adopt_ref(*new Loader(path)); }
static NonnullRefPtr<Loader> create(StringView path) { return adopt_ref(*new Loader(path)); }
static NonnullRefPtr<Loader> create(const ByteBuffer& buffer) { return adopt_ref(*new Loader(buffer)); }
bool has_error() const { return m_plugin ? m_plugin->has_error() : true; }
@ -78,7 +78,7 @@ public:
RefPtr<Core::File> file() const { return m_plugin ? m_plugin->file() : nullptr; }
private:
Loader(const StringView& path);
Loader(StringView path);
Loader(const ByteBuffer& buffer);
mutable OwnPtr<LoaderPlugin> m_plugin;

View file

@ -17,7 +17,7 @@ namespace Audio {
static constexpr size_t maximum_wav_size = 1 * GiB; // FIXME: is there a more appropriate size limit?
WavLoaderPlugin::WavLoaderPlugin(const StringView& path)
WavLoaderPlugin::WavLoaderPlugin(StringView path)
: m_file(Core::File::construct(path))
{
if (!m_file->open(Core::OpenMode::ReadOnly)) {

View file

@ -33,7 +33,7 @@ class Buffer;
// Parses a WAV file and produces an Audio::Buffer.
class WavLoaderPlugin : public LoaderPlugin {
public:
WavLoaderPlugin(const StringView& path);
WavLoaderPlugin(StringView path);
WavLoaderPlugin(const ByteBuffer& buffer);
virtual bool sniff() override { return valid; }

View file

@ -8,7 +8,7 @@
namespace Audio {
WavWriter::WavWriter(const StringView& path, int sample_rate, int num_channels, int bits_per_sample)
WavWriter::WavWriter(StringView path, int sample_rate, int num_channels, int bits_per_sample)
: m_sample_rate(sample_rate)
, m_num_channels(num_channels)
, m_bits_per_sample(bits_per_sample)
@ -29,7 +29,7 @@ WavWriter::~WavWriter()
finalize();
}
void WavWriter::set_file(const StringView& path)
void WavWriter::set_file(StringView path)
{
m_file = Core::File::construct(path);
if (!m_file->open(Core::OpenMode::ReadWrite)) {

View file

@ -13,7 +13,7 @@ namespace Audio {
class WavWriter {
public:
WavWriter(const StringView& path, int sample_rate = 44100, int num_channels = 2, int bits_per_sample = 16);
WavWriter(StringView path, int sample_rate = 44100, int num_channels = 2, int bits_per_sample = 16);
WavWriter(int sample_rate = 44100, int num_channels = 2, int bits_per_sample = 16);
~WavWriter();
@ -28,7 +28,7 @@ public:
u16 bits_per_sample() const { return m_bits_per_sample; }
RefPtr<Core::File> file() const { return m_file; }
void set_file(const StringView& path);
void set_file(StringView path);
void set_num_channels(int num_channels) { m_num_channels = num_channels; }
void set_sample_rate(int sample_rate) { m_sample_rate = sample_rate; }
void set_bits_per_sample(int bits_per_sample) { m_bits_per_sample = bits_per_sample; }

View file

@ -41,7 +41,7 @@ namespace {
class OptionParser {
public:
OptionParser(int argc, char* const* argv, const StringView& short_options, const option* long_options, int* out_long_option_index = nullptr);
OptionParser(int argc, char* const* argv, StringView short_options, const option* long_options, int* out_long_option_index = nullptr);
int getopt();
private:
@ -65,7 +65,7 @@ private:
size_t m_consumed_args { 0 };
};
OptionParser::OptionParser(int argc, char* const* argv, const StringView& short_options, const option* long_options, int* out_long_option_index)
OptionParser::OptionParser(int argc, char* const* argv, StringView short_options, const option* long_options, int* out_long_option_index)
: m_argc(argc)
, m_argv(argv)
, m_short_options(short_options)

View file

@ -32,7 +32,7 @@ String char_for_piece(Chess::Type type)
}
}
Chess::Type piece_for_char_promotion(const StringView& str)
Chess::Type piece_for_char_promotion(StringView str)
{
String string = String(str).to_lowercase();
if (string == "")
@ -56,7 +56,7 @@ Color opposing_color(Color color)
return (color == Color::White) ? Color::Black : Color::White;
}
Square::Square(const StringView& name)
Square::Square(StringView name)
{
VERIFY(name.length() == 2);
char filec = name[0];
@ -85,7 +85,7 @@ String Square::to_algebraic() const
return builder.build();
}
Move::Move(const StringView& long_algebraic)
Move::Move(StringView long_algebraic)
: from(long_algebraic.substring_view(0, 2))
, to(long_algebraic.substring_view(2, 2))
, promote_to(piece_for_char_promotion((long_algebraic.length() >= 5) ? long_algebraic.substring_view(4, 1) : ""))
@ -101,7 +101,7 @@ String Move::to_long_algebraic() const
return builder.build();
}
Move Move::from_algebraic(const StringView& algebraic, const Color turn, const Board& board)
Move Move::from_algebraic(StringView algebraic, const Color turn, const Board& board)
{
String move_string = algebraic;
Move move({ 50, 50 }, { 50, 50 });

View file

@ -26,7 +26,7 @@ enum class Type : u8 {
};
String char_for_piece(Type type);
Chess::Type piece_for_char_promotion(const StringView& str);
Chess::Type piece_for_char_promotion(StringView str);
enum class Color : u8 {
White,
@ -57,7 +57,7 @@ constexpr Piece EmptyPiece = { Color::None, Type::None };
struct Square {
i8 rank; // zero indexed;
i8 file;
Square(const StringView& name);
Square(StringView name);
Square(const int& rank, const int& file)
: rank(rank)
, file(file)
@ -93,7 +93,7 @@ struct Move {
bool is_capture : 1 = false;
bool is_ambiguous : 1 = false;
Square ambiguous { 50, 50 };
Move(const StringView& long_algebraic);
Move(StringView long_algebraic);
Move(const Square& from, const Square& to, const Type& promote_to = Type::None)
: from(from)
, to(to)
@ -102,7 +102,7 @@ struct Move {
}
bool operator==(const Move& other) const { return from == other.from && to == other.to && promote_to == other.promote_to; }
static Move from_algebraic(const StringView& algebraic, const Color turn, const Board& board);
static Move from_algebraic(StringView algebraic, const Color turn, const Board& board);
String to_long_algebraic() const;
String to_algebraic() const;
};

View file

@ -9,7 +9,7 @@
namespace Chess::UCI {
UCICommand UCICommand::from_string(const StringView& command)
UCICommand UCICommand::from_string(StringView command)
{
auto tokens = command.split_view(' ');
VERIFY(tokens[0] == "uci");
@ -22,7 +22,7 @@ String UCICommand::to_string() const
return "uci\n";
}
DebugCommand DebugCommand::from_string(const StringView& command)
DebugCommand DebugCommand::from_string(StringView command)
{
auto tokens = command.split_view(' ');
VERIFY(tokens[0] == "debug");
@ -44,7 +44,7 @@ String DebugCommand::to_string() const
}
}
IsReadyCommand IsReadyCommand::from_string(const StringView& command)
IsReadyCommand IsReadyCommand::from_string(StringView command)
{
auto tokens = command.split_view(' ');
VERIFY(tokens[0] == "isready");
@ -57,7 +57,7 @@ String IsReadyCommand::to_string() const
return "isready\n";
}
SetOptionCommand SetOptionCommand::from_string(const StringView& command)
SetOptionCommand SetOptionCommand::from_string(StringView command)
{
auto tokens = command.split_view(' ');
VERIFY(tokens[0] == "setoption");
@ -108,7 +108,7 @@ String SetOptionCommand::to_string() const
return builder.build();
}
PositionCommand PositionCommand::from_string(const StringView& command)
PositionCommand PositionCommand::from_string(StringView command)
{
auto tokens = command.split_view(' ');
VERIFY(tokens.size() >= 3);
@ -144,7 +144,7 @@ String PositionCommand::to_string() const
return builder.build();
}
GoCommand GoCommand::from_string(const StringView& command)
GoCommand GoCommand::from_string(StringView command)
{
auto tokens = command.split_view(' ');
VERIFY(tokens[0] == "go");
@ -230,7 +230,7 @@ String GoCommand::to_string() const
return builder.build();
}
StopCommand StopCommand::from_string(const StringView& command)
StopCommand StopCommand::from_string(StringView command)
{
auto tokens = command.split_view(' ');
VERIFY(tokens[0] == "stop");
@ -243,7 +243,7 @@ String StopCommand::to_string() const
return "stop\n";
}
IdCommand IdCommand::from_string(const StringView& command)
IdCommand IdCommand::from_string(StringView command)
{
auto tokens = command.split_view(' ');
VERIFY(tokens[0] == "id");
@ -277,7 +277,7 @@ String IdCommand::to_string() const
return builder.build();
}
UCIOkCommand UCIOkCommand::from_string(const StringView& command)
UCIOkCommand UCIOkCommand::from_string(StringView command)
{
auto tokens = command.split_view(' ');
VERIFY(tokens[0] == "uciok");
@ -290,7 +290,7 @@ String UCIOkCommand::to_string() const
return "uciok\n";
}
ReadyOkCommand ReadyOkCommand::from_string(const StringView& command)
ReadyOkCommand ReadyOkCommand::from_string(StringView command)
{
auto tokens = command.split_view(' ');
VERIFY(tokens[0] == "readyok");
@ -303,7 +303,7 @@ String ReadyOkCommand::to_string() const
return "readyok\n";
}
BestMoveCommand BestMoveCommand::from_string(const StringView& command)
BestMoveCommand BestMoveCommand::from_string(StringView command)
{
auto tokens = command.split_view(' ');
VERIFY(tokens[0] == "bestmove");
@ -320,7 +320,7 @@ String BestMoveCommand::to_string() const
return builder.build();
}
InfoCommand InfoCommand::from_string([[maybe_unused]] const StringView& command)
InfoCommand InfoCommand::from_string([[maybe_unused]] StringView command)
{
// FIXME: Implement this.
VERIFY_NOT_REACHED();

View file

@ -56,7 +56,7 @@ public:
{
}
static UCICommand from_string(const StringView& command);
static UCICommand from_string(StringView command);
virtual String to_string() const;
};
@ -74,7 +74,7 @@ public:
{
}
static DebugCommand from_string(const StringView& command);
static DebugCommand from_string(StringView command);
virtual String to_string() const;
@ -91,21 +91,21 @@ public:
{
}
static IsReadyCommand from_string(const StringView& command);
static IsReadyCommand from_string(StringView command);
virtual String to_string() const;
};
class SetOptionCommand : public Command {
public:
explicit SetOptionCommand(const StringView& name, Optional<String> value = {})
explicit SetOptionCommand(StringView name, Optional<String> value = {})
: Command(Command::Type::SetOption)
, m_name(name)
, m_value(value)
{
}
static SetOptionCommand from_string(const StringView& command);
static SetOptionCommand from_string(StringView command);
virtual String to_string() const;
@ -126,7 +126,7 @@ public:
{
}
static PositionCommand from_string(const StringView& command);
static PositionCommand from_string(StringView command);
virtual String to_string() const;
@ -145,7 +145,7 @@ public:
{
}
static GoCommand from_string(const StringView& command);
static GoCommand from_string(StringView command);
virtual String to_string() const;
@ -170,7 +170,7 @@ public:
{
}
static StopCommand from_string(const StringView& command);
static StopCommand from_string(StringView command);
virtual String to_string() const;
};
@ -182,14 +182,14 @@ public:
Author,
};
explicit IdCommand(Type field_type, const StringView& value)
explicit IdCommand(Type field_type, StringView value)
: Command(Command::Type::Id)
, m_field_type(field_type)
, m_value(value)
{
}
static IdCommand from_string(const StringView& command);
static IdCommand from_string(StringView command);
virtual String to_string() const;
@ -208,7 +208,7 @@ public:
{
}
static UCIOkCommand from_string(const StringView& command);
static UCIOkCommand from_string(StringView command);
virtual String to_string() const;
};
@ -220,7 +220,7 @@ public:
{
}
static ReadyOkCommand from_string(const StringView& command);
static ReadyOkCommand from_string(StringView command);
virtual String to_string() const;
};
@ -233,7 +233,7 @@ public:
{
}
static BestMoveCommand from_string(const StringView& command);
static BestMoveCommand from_string(StringView command);
virtual String to_string() const;
@ -250,7 +250,7 @@ public:
{
}
static InfoCommand from_string(const StringView& command);
static InfoCommand from_string(StringView command);
virtual String to_string() const;

View file

@ -294,7 +294,7 @@ void IODevice::set_fd(int fd)
did_update_fd(fd);
}
bool IODevice::write(const StringView& v)
bool IODevice::write(StringView v)
{
return write((const u8*)v.characters_without_null_termination(), v.length());
}

View file

@ -75,7 +75,7 @@ public:
String read_line(size_t max_size = 16384);
bool write(const u8*, int size);
bool write(const StringView&);
bool write(StringView);
bool truncate(off_t);

View file

@ -50,7 +50,7 @@ void MimeData::set_text(const String& text)
set_data("text/plain", text.to_byte_buffer());
}
String guess_mime_type_based_on_filename(const StringView& path)
String guess_mime_type_based_on_filename(StringView path)
{
if (path.ends_with(".pbm", CaseSensitivity::CaseInsensitive))
return "image/xportablebitmap";

View file

@ -47,7 +47,7 @@ private:
HashMap<String, ByteBuffer> m_data;
};
String guess_mime_type_based_on_filename(const StringView&);
String guess_mime_type_based_on_filename(StringView);
Optional<String> guess_mime_type_based_on_sniffed_bytes(const ReadonlyBytes&);

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 };

View file

@ -73,7 +73,7 @@ String type_name(Type type)
return "InvalidType";
}
Optional<Core::DateTime> parse_utc_time(const StringView& time)
Optional<Core::DateTime> parse_utc_time(StringView time)
{
// YYMMDDhhmm[ss]Z or YYMMDDhhmm[ss](+|-)hhmm
GenericLexer lexer(time);
@ -120,7 +120,7 @@ Optional<Core::DateTime> parse_utc_time(const StringView& time)
return Core::DateTime::create(full_year, month.value(), day.value(), hour.value(), minute.value(), full_seconds);
}
Optional<Core::DateTime> parse_generalized_time(const StringView& time)
Optional<Core::DateTime> parse_generalized_time(StringView time)
{
// YYYYMMDDhh[mm[ss[.fff]]] or YYYYMMDDhh[mm[ss[.fff]]]Z or YYYYMMDDhh[mm[ss[.fff]]](+|-)hhmm
GenericLexer lexer(time);

View file

@ -52,7 +52,7 @@ String kind_name(Kind);
String class_name(Class);
String type_name(Type);
Optional<Core::DateTime> parse_utc_time(const StringView&);
Optional<Core::DateTime> parse_generalized_time(const StringView&);
Optional<Core::DateTime> parse_utc_time(StringView);
Optional<Core::DateTime> parse_generalized_time(StringView);
}

View file

@ -49,10 +49,10 @@ public:
}
TagType process(ReadonlyBytes span) { return process(span.data(), span.size()); }
TagType process(const StringView& string) { return process((const u8*)string.characters_without_null_termination(), string.length()); }
TagType process(StringView string) { return process((const u8*)string.characters_without_null_termination(), string.length()); }
void update(ReadonlyBytes span) { return update(span.data(), span.size()); }
void update(const StringView& string) { return update((const u8*)string.characters_without_null_termination(), string.length()); }
void update(StringView string) { return update((const u8*)string.characters_without_null_termination(), string.length()); }
TagType digest()
{
@ -110,7 +110,7 @@ private:
}
void derive_key(ReadonlyBytes key) { derive_key(key.data(), key.size()); }
void derive_key(const StringView& key) { derive_key(key.bytes()); }
void derive_key(StringView key) { derive_key(key.bytes()); }
HashType m_inner_hasher, m_outer_hasher;
u8 m_key_data[2048];

View file

@ -44,7 +44,7 @@ public:
return { UnsignedBigInteger::create_invalid(), false };
}
static SignedBigInteger import_data(const StringView& data) { return import_data((const u8*)data.characters_without_null_termination(), data.length()); }
static SignedBigInteger import_data(StringView data) { return import_data((const u8*)data.characters_without_null_termination(), data.length()); }
static SignedBigInteger import_data(const u8* ptr, size_t length);
static SignedBigInteger create_from(i64 value)

View file

@ -35,7 +35,7 @@ public:
static UnsignedBigInteger create_invalid();
static UnsignedBigInteger import_data(const StringView& data) { return import_data((const u8*)data.characters_without_null_termination(), data.length()); }
static UnsignedBigInteger import_data(StringView data) { return import_data((const u8*)data.characters_without_null_termination(), data.length()); }
static UnsignedBigInteger import_data(const u8* ptr, size_t length)
{
return UnsignedBigInteger(ptr, length);

View file

@ -29,7 +29,7 @@ public:
void update(const Bytes& buffer) { update(buffer.data(), buffer.size()); };
void update(const ReadonlyBytes& buffer) { update(buffer.data(), buffer.size()); };
void update(const ByteBuffer& buffer) { update(buffer.data(), buffer.size()); };
void update(const StringView& string) { update((const u8*)string.characters_without_null_termination(), string.length()); };
void update(StringView string) { update((const u8*)string.characters_without_null_termination(), string.length()); };
virtual DigestType peek() = 0;
virtual DigestType digest() = 0;

View file

@ -71,7 +71,7 @@ public:
}
inline static DigestType hash(const ByteBuffer& buffer) { return hash(buffer.data(), buffer.size()); }
inline static DigestType hash(const StringView& buffer) { return hash((const u8*)buffer.characters_without_null_termination(), buffer.length()); }
inline static DigestType hash(StringView buffer) { return hash((const u8*)buffer.characters_without_null_termination(), buffer.length()); }
inline virtual void reset() override
{
m_A = MD5Constants::init_A;

View file

@ -56,7 +56,7 @@ public:
}
inline static DigestType hash(const ByteBuffer& buffer) { return hash(buffer.data(), buffer.size()); }
inline static DigestType hash(const StringView& buffer) { return hash((const u8*)buffer.characters_without_null_termination(), buffer.length()); }
inline static DigestType hash(StringView buffer) { return hash((const u8*)buffer.characters_without_null_termination(), buffer.length()); }
virtual String class_name() const override
{

View file

@ -103,7 +103,7 @@ public:
}
inline static DigestType hash(const ByteBuffer& buffer) { return hash(buffer.data(), buffer.size()); }
inline static DigestType hash(const StringView& buffer) { return hash((const u8*)buffer.characters_without_null_termination(), buffer.length()); }
inline static DigestType hash(StringView buffer) { return hash((const u8*)buffer.characters_without_null_termination(), buffer.length()); }
virtual String class_name() const override
{
@ -153,7 +153,7 @@ public:
}
inline static DigestType hash(const ByteBuffer& buffer) { return hash(buffer.data(), buffer.size()); }
inline static DigestType hash(const StringView& buffer) { return hash((const u8*)buffer.characters_without_null_termination(), buffer.length()); }
inline static DigestType hash(StringView buffer) { return hash((const u8*)buffer.characters_without_null_termination(), buffer.length()); }
virtual String class_name() const override
{
@ -203,7 +203,7 @@ public:
}
inline static DigestType hash(const ByteBuffer& buffer) { return hash(buffer.data(), buffer.size()); }
inline static DigestType hash(const StringView& buffer) { return hash((const u8*)buffer.characters_without_null_termination(), buffer.length()); }
inline static DigestType hash(StringView buffer) { return hash((const u8*)buffer.characters_without_null_termination(), buffer.length()); }
virtual String class_name() const override
{

View file

@ -141,7 +141,7 @@ public:
import_private_key(privateKeyPEM);
}
RSA(const StringView& privKeyPEM)
RSA(StringView privKeyPEM)
{
import_private_key(privKeyPEM.bytes());
m_public_key.set(m_private_key.modulus(), m_private_key.public_exponent());

View file

@ -29,7 +29,7 @@ DwarfInfo::DwarfInfo(ELF::Image const& elf)
populate_compilation_units();
}
ReadonlyBytes DwarfInfo::section_data(StringView const& section_name) const
ReadonlyBytes DwarfInfo::section_data(StringView section_name) const
{
auto section = m_elf.lookup_section(section_name);
if (!section.has_value())

View file

@ -53,7 +53,7 @@ private:
void populate_compilation_units();
void build_cached_dies() const;
ReadonlyBytes section_data(StringView const& section_name) const;
ReadonlyBytes section_data(StringView section_name) const;
ELF::Image const& m_elf;
ReadonlyBytes m_debug_info_data;

View file

@ -14,18 +14,18 @@
namespace Desktop {
NonnullRefPtr<AppFile> AppFile::get_for_app(const StringView& app_name)
NonnullRefPtr<AppFile> AppFile::get_for_app(StringView app_name)
{
auto path = String::formatted("{}/{}.af", APP_FILES_DIRECTORY, app_name);
return open(path);
}
NonnullRefPtr<AppFile> AppFile::open(const StringView& path)
NonnullRefPtr<AppFile> AppFile::open(StringView path)
{
return adopt_ref(*new AppFile(path));
}
void AppFile::for_each(Function<void(NonnullRefPtr<AppFile>)> callback, const StringView& directory)
void AppFile::for_each(Function<void(NonnullRefPtr<AppFile>)> callback, StringView directory)
{
Core::DirIterator di(directory, Core::DirIterator::SkipDots);
if (di.has_error())
@ -42,7 +42,7 @@ void AppFile::for_each(Function<void(NonnullRefPtr<AppFile>)> callback, const St
}
}
AppFile::AppFile(const StringView& path)
AppFile::AppFile(StringView path)
: m_config(Core::ConfigFile::open(path))
, m_valid(validate())
{

View file

@ -15,9 +15,9 @@ namespace Desktop {
class AppFile : public RefCounted<AppFile> {
public:
static constexpr const char* APP_FILES_DIRECTORY = "/res/apps";
static NonnullRefPtr<AppFile> get_for_app(const StringView& app_name);
static NonnullRefPtr<AppFile> open(const StringView& path);
static void for_each(Function<void(NonnullRefPtr<AppFile>)>, const StringView& directory = APP_FILES_DIRECTORY);
static NonnullRefPtr<AppFile> get_for_app(StringView app_name);
static NonnullRefPtr<AppFile> open(StringView path);
static void for_each(Function<void(NonnullRefPtr<AppFile>)>, StringView directory = APP_FILES_DIRECTORY);
~AppFile();
bool is_valid() const { return m_valid; }
@ -35,7 +35,7 @@ public:
bool spawn() const;
private:
explicit AppFile(const StringView& path);
explicit AppFile(StringView path);
bool validate() const;

View file

@ -8,7 +8,7 @@
namespace Diff {
Vector<Hunk> from_text(StringView const& old_text, StringView const& new_text)
Vector<Hunk> from_text(StringView old_text, StringView new_text)
{
auto old_lines = old_text.lines();
auto new_lines = new_text.lines();

View file

@ -10,6 +10,6 @@
namespace Diff {
Vector<Hunk> from_text(StringView const& old_text, StringView const& new_text);
Vector<Hunk> from_text(StringView old_text, StringView new_text);
}

View file

@ -58,7 +58,7 @@ static Result<void*, DlErrorMessage> __dlopen(const char* filename, int flags);
static Result<void*, DlErrorMessage> __dlsym(void* handle, const char* symbol_name);
static Result<void, DlErrorMessage> __dladdr(void* addr, Dl_info* info);
Optional<DynamicObject::SymbolLookupResult> DynamicLinker::lookup_global_symbol(const StringView& name)
Optional<DynamicObject::SymbolLookupResult> DynamicLinker::lookup_global_symbol(StringView name)
{
Optional<DynamicObject::SymbolLookupResult> weak_result;

View file

@ -14,7 +14,7 @@ namespace ELF {
class DynamicLinker {
public:
static Optional<DynamicObject::SymbolLookupResult> lookup_global_symbol(const StringView& symbol);
static Optional<DynamicObject::SymbolLookupResult> lookup_global_symbol(StringView symbol);
[[noreturn]] static void linker_main(String&& main_program_name, int fd, bool is_secure, int argc, char** argv, char** envp);
private:

View file

@ -249,7 +249,7 @@ const ElfW(Phdr) * DynamicObject::program_headers() const
return (const ElfW(Phdr)*)(m_base_address.as_ptr() + header->e_phoff);
}
auto DynamicObject::HashSection::lookup_sysv_symbol(const StringView& name, u32 hash_value) const -> Optional<Symbol>
auto DynamicObject::HashSection::lookup_sysv_symbol(StringView name, u32 hash_value) const -> Optional<Symbol>
{
u32* hash_table_begin = (u32*)address().as_ptr();
size_t num_buckets = hash_table_begin[0];
@ -273,7 +273,7 @@ auto DynamicObject::HashSection::lookup_sysv_symbol(const StringView& name, u32
return {};
}
auto DynamicObject::HashSection::lookup_gnu_symbol(const StringView& name, u32 hash_value) const -> Optional<Symbol>
auto DynamicObject::HashSection::lookup_gnu_symbol(StringView name, u32 hash_value) const -> Optional<Symbol>
{
// Algorithm reference: https://ent-voy.blogspot.com/2011/02/
using BloomWord = FlatPtr;
@ -437,7 +437,7 @@ const char* DynamicObject::name_for_dtag(ElfW(Sword) d_tag)
}
}
auto DynamicObject::lookup_symbol(const StringView& name) const -> Optional<SymbolLookupResult>
auto DynamicObject::lookup_symbol(StringView name) const -> Optional<SymbolLookupResult>
{
return lookup_symbol(HashSymbol { name });
}
@ -500,7 +500,7 @@ u32 DynamicObject::HashSymbol::sysv_hash() const
return m_sysv_hash.value();
}
void* DynamicObject::symbol_for_name(const StringView& name)
void* DynamicObject::symbol_for_name(StringView name)
{
auto result = hash_section().lookup_symbol(name);
if (!result.has_value())

View file

@ -99,7 +99,7 @@ public:
class Section {
public:
Section(const DynamicObject& dynamic, unsigned section_offset, unsigned section_size_bytes, unsigned entry_size, const StringView& name)
Section(const DynamicObject& dynamic, unsigned section_offset, unsigned section_size_bytes, unsigned entry_size, StringView name)
: m_dynamic(dynamic)
, m_section_offset(section_offset)
, m_section_size_bytes(section_size_bytes)
@ -212,7 +212,7 @@ public:
class HashSymbol {
public:
HashSymbol(const StringView& name)
HashSymbol(StringView name)
: m_name(name)
{
}
@ -243,8 +243,8 @@ public:
}
private:
Optional<Symbol> lookup_sysv_symbol(const StringView& name, u32 hash_value) const;
Optional<Symbol> lookup_gnu_symbol(const StringView& name, u32 hash) const;
Optional<Symbol> lookup_sysv_symbol(StringView name, u32 hash_value) const;
Optional<Symbol> lookup_gnu_symbol(StringView name, u32 hash) const;
HashType m_hash_type {};
};
@ -320,7 +320,7 @@ public:
const ELF::DynamicObject* dynamic_object { nullptr }; // The object in which the symbol is defined
};
Optional<SymbolLookupResult> lookup_symbol(const StringView& name) const;
Optional<SymbolLookupResult> lookup_symbol(StringView name) const;
Optional<SymbolLookupResult> lookup_symbol(const HashSymbol& symbol) const;
// Will be called from _fixup_plt_entry, as part of the PLT trampoline
@ -328,7 +328,7 @@ public:
bool elf_is_dynamic() const { return m_is_elf_dynamic; }
void* symbol_for_name(const StringView& name);
void* symbol_for_name(StringView name);
private:
explicit DynamicObject(const String& filename, VirtualAddress base_address, VirtualAddress dynamic_section_address);

View file

@ -11,7 +11,7 @@
namespace ELF {
constexpr u32 compute_sysv_hash(const StringView& name)
constexpr u32 compute_sysv_hash(StringView name)
{
// SYSV ELF hash algorithm
// Note that the GNU HASH algorithm has less collisions
@ -30,7 +30,7 @@ constexpr u32 compute_sysv_hash(const StringView& name)
return hash;
}
constexpr u32 compute_gnu_hash(const StringView& name)
constexpr u32 compute_gnu_hash(StringView name)
{
// GNU ELF hash algorithm
u32 hash = 5381;

View file

@ -252,7 +252,7 @@ Optional<Image::RelocationSection> Image::Section::relocations() const
return static_cast<RelocationSection>(relocation_section.value());
}
Optional<Image::Section> Image::lookup_section(const StringView& name) const
Optional<Image::Section> Image::lookup_section(StringView name) const
{
VERIFY(m_valid);
for (unsigned i = 0; i < section_count(); ++i) {
@ -354,7 +354,7 @@ StringView Image::Symbol::raw_data() const
}
#ifndef KERNEL
Optional<Image::Symbol> Image::find_demangled_function(const StringView& name) const
Optional<Image::Symbol> Image::find_demangled_function(StringView name) const
{
Optional<Image::Symbol> found;
for_each_symbol([&](const Image::Symbol& symbol) {

View file

@ -217,7 +217,7 @@ public:
template<VoidFunction<ProgramHeader> F>
void for_each_program_header(F) const;
Optional<Section> lookup_section(StringView const& name) const;
Optional<Section> lookup_section(StringView name) const;
bool is_executable() const { return header().e_type == ET_EXEC; }
bool is_relocatable() const { return header().e_type == ET_REL; }
@ -233,7 +233,7 @@ public:
bool has_symbols() const { return symbol_count(); }
#ifndef KERNEL
Optional<Symbol> find_demangled_function(const StringView& name) const;
Optional<Symbol> find_demangled_function(StringView name) const;
String symbolicate(FlatPtr address, u32* offset = nullptr) const;
#endif
Optional<Image::Symbol> find_symbol(FlatPtr address, u32* offset = nullptr) const;

View file

@ -68,7 +68,7 @@ Result Client::request_file(i32 parent_window_id, String const& path, Core::Open
return m_promise->await();
}
Result Client::open_file(i32 parent_window_id, String const& window_title, StringView const& path)
Result Client::open_file(i32 parent_window_id, String const& window_title, StringView path)
{
m_promise = Core::Promise<Result>::construct();
auto parent_window_server_client_id = GUI::WindowServerConnection::the().expose_client_id();

View file

@ -29,7 +29,7 @@ class Client final
public:
Result request_file_read_only_approved(i32 parent_window_id, String const& path);
Result request_file(i32 parent_window_id, String const& path, Core::OpenMode mode);
Result open_file(i32 parent_window_id, String const& window_title = {}, StringView const& path = Core::StandardPaths::home_directory());
Result open_file(i32 parent_window_id, String const& window_title = {}, StringView path = Core::StandardPaths::home_directory());
Result save_file(i32 parent_window_id, String const& name, String const ext);
static Client& the();

View file

@ -16,7 +16,7 @@
namespace GUI {
AboutDialog::AboutDialog(const StringView& name, const Gfx::Bitmap* icon, Window* parent_window, const StringView& version)
AboutDialog::AboutDialog(StringView name, const Gfx::Bitmap* icon, Window* parent_window, StringView version)
: Dialog(parent_window)
, m_name(name)
, m_icon(icon)
@ -58,7 +58,7 @@ AboutDialog::AboutDialog(const StringView& name, const Gfx::Bitmap* icon, Window
right_container.set_layout<VerticalBoxLayout>();
right_container.layout()->set_margins({ 12, 4, 4, 0 });
auto make_label = [&](const StringView& text, bool bold = false) {
auto make_label = [&](StringView text, bool bold = false) {
auto& label = right_container.add<Label>(text);
label.set_text_alignment(Gfx::TextAlignment::CenterLeft);
label.set_fixed_height(14);

View file

@ -16,7 +16,7 @@ class AboutDialog final : public Dialog {
public:
virtual ~AboutDialog() override;
static void show(const StringView& name, const Gfx::Bitmap* icon = nullptr, Window* parent_window = nullptr, const Gfx::Bitmap* window_icon = nullptr, const StringView& version = Core::Version::SERENITY_VERSION)
static void show(StringView name, const Gfx::Bitmap* icon = nullptr, Window* parent_window = nullptr, const Gfx::Bitmap* window_icon = nullptr, StringView version = Core::Version::SERENITY_VERSION)
{
auto dialog = AboutDialog::construct(name, icon, parent_window, version);
if (window_icon)
@ -25,7 +25,7 @@ public:
}
private:
AboutDialog(const StringView& name, const Gfx::Bitmap* icon = nullptr, Window* parent_window = nullptr, const StringView& version = Core::Version::SERENITY_VERSION);
AboutDialog(StringView name, const Gfx::Bitmap* icon = nullptr, Window* parent_window = nullptr, StringView version = Core::Version::SERENITY_VERSION);
String m_name;
RefPtr<Gfx::Bitmap> m_icon;

View file

@ -684,7 +684,7 @@ void AbstractView::set_searchable(bool searchable)
stop_highlighted_search_timer();
}
void AbstractView::draw_item_text(Gfx::Painter& painter, ModelIndex const& index, bool is_selected, Gfx::IntRect const& text_rect, StringView const& item_text, Gfx::Font const& font, Gfx::TextAlignment alignment, Gfx::TextElision elision, size_t search_highlighting_offset)
void AbstractView::draw_item_text(Gfx::Painter& painter, ModelIndex const& index, bool is_selected, Gfx::IntRect const& text_rect, StringView item_text, Gfx::Font const& font, Gfx::TextAlignment alignment, Gfx::TextElision elision, size_t search_highlighting_offset)
{
if (m_edit_index == index)
return;

View file

@ -154,7 +154,7 @@ protected:
virtual void did_change_cursor_index([[maybe_unused]] ModelIndex const& old_index, [[maybe_unused]] ModelIndex const& new_index) { }
virtual void editing_widget_did_change([[maybe_unused]] ModelIndex const& index) { }
void draw_item_text(Gfx::Painter&, ModelIndex const&, bool, Gfx::IntRect const&, StringView const&, Gfx::Font const&, Gfx::TextAlignment, Gfx::TextElision, size_t search_highlighting_offset = 0);
void draw_item_text(Gfx::Painter&, ModelIndex const&, bool, Gfx::IntRect const&, StringView, Gfx::Font const&, Gfx::TextAlignment, Gfx::TextElision, size_t search_highlighting_offset = 0);
void set_suppress_update_on_selection_change(bool value) { m_suppress_update_on_selection_change = value; }

View file

@ -141,7 +141,7 @@ ComboBox::~ComboBox()
{
}
void ComboBox::set_editor_placeholder(const StringView& placeholder)
void ComboBox::set_editor_placeholder(StringView placeholder)
{
m_editor->set_placeholder(placeholder);
}

View file

@ -40,7 +40,7 @@ public:
int model_column() const;
void set_model_column(int);
void set_editor_placeholder(const StringView& placeholder);
void set_editor_placeholder(StringView placeholder);
const String& editor_placeholder() const;
Function<void(const String&, const ModelIndex&)> on_change;

View file

@ -45,17 +45,17 @@ void Desktop::did_receive_screen_rects(Badge<WindowServerConnection>, const Vect
callback(*this);
}
void Desktop::set_background_color(const StringView& background_color)
void Desktop::set_background_color(StringView background_color)
{
WindowServerConnection::the().async_set_background_color(background_color);
}
void Desktop::set_wallpaper_mode(const StringView& mode)
void Desktop::set_wallpaper_mode(StringView mode)
{
WindowServerConnection::the().async_set_wallpaper_mode(mode);
}
bool Desktop::set_wallpaper(const StringView& path, bool save_config)
bool Desktop::set_wallpaper(StringView path, bool save_config)
{
WindowServerConnection::the().async_set_wallpaper(path);
auto ret_val = WindowServerConnection::the().wait_for_specific_message<Messages::WindowClient::SetWallpaperFinished>()->success();

View file

@ -25,12 +25,12 @@ public:
static Desktop& the();
Desktop();
void set_background_color(const StringView& background_color);
void set_background_color(StringView background_color);
void set_wallpaper_mode(const StringView& mode);
void set_wallpaper_mode(StringView mode);
String wallpaper() const;
bool set_wallpaper(const StringView& path, bool save_config = true);
bool set_wallpaper(StringView path, bool save_config = true);
Gfx::IntRect rect() const { return m_bounding_rect; }
const Vector<Gfx::IntRect, 4>& rects() const { return m_rects; }

View file

@ -26,7 +26,7 @@ static Vector<u32> supported_emoji_code_points()
auto lexical_path = LexicalPath(filename);
if (lexical_path.extension() != "png")
continue;
auto& basename = lexical_path.basename();
auto basename = lexical_path.basename();
if (!basename.starts_with("U+"))
continue;
u32 code_point = strtoul(basename.to_string().characters() + 2, nullptr, 16);

View file

@ -138,7 +138,7 @@ public:
class WMWindowStateChangedEvent : public WMEvent {
public:
WMWindowStateChangedEvent(int client_id, int window_id, int parent_client_id, int parent_window_id, const StringView& title, const Gfx::IntRect& rect, unsigned virtual_desktop_row, unsigned virtual_desktop_column, bool is_active, bool is_modal, WindowType window_type, bool is_minimized, bool is_frameless, Optional<int> progress)
WMWindowStateChangedEvent(int client_id, int window_id, int parent_client_id, int parent_window_id, StringView title, const Gfx::IntRect& rect, unsigned virtual_desktop_row, unsigned virtual_desktop_column, bool is_active, bool is_modal, WindowType window_type, bool is_minimized, bool is_frameless, Optional<int> progress)
: WMEvent(Event::Type::WM_WindowStateChanged, client_id, window_id)
, m_parent_client_id(parent_client_id)
, m_parent_window_id(parent_window_id)

View file

@ -32,7 +32,7 @@
namespace GUI {
Optional<String> FilePicker::get_open_filepath(Window* parent_window, const String& window_title, const StringView& path, bool folder, ScreenPosition screen_position)
Optional<String> FilePicker::get_open_filepath(Window* parent_window, const String& window_title, StringView path, bool folder, ScreenPosition screen_position)
{
auto picker = FilePicker::construct(parent_window, folder ? Mode::OpenFolder : Mode::Open, "", path, screen_position);
@ -50,7 +50,7 @@ Optional<String> FilePicker::get_open_filepath(Window* parent_window, const Stri
return {};
}
Optional<String> FilePicker::get_save_filepath(Window* parent_window, const String& title, const String& extension, const StringView& path, ScreenPosition screen_position)
Optional<String> FilePicker::get_save_filepath(Window* parent_window, const String& title, const String& extension, StringView path, ScreenPosition screen_position)
{
auto picker = FilePicker::construct(parent_window, Mode::Save, String::formatted("{}.{}", title, extension), path, screen_position);
@ -65,7 +65,7 @@ Optional<String> FilePicker::get_save_filepath(Window* parent_window, const Stri
return {};
}
FilePicker::FilePicker(Window* parent_window, Mode mode, const StringView& filename, const StringView& path, ScreenPosition screen_position)
FilePicker::FilePicker(Window* parent_window, Mode mode, StringView filename, StringView path, ScreenPosition screen_position)
: Dialog(parent_window, screen_position)
, m_model(FileSystemModel::create(path))
, m_mode(mode)

View file

@ -28,8 +28,8 @@ public:
Save
};
static Optional<String> get_open_filepath(Window* parent_window, const String& window_title = {}, const StringView& path = Core::StandardPaths::home_directory(), bool folder = false, ScreenPosition screen_position = Dialog::ScreenPosition::CenterWithinParent);
static Optional<String> get_save_filepath(Window* parent_window, const String& title, const String& extension, const StringView& path = Core::StandardPaths::home_directory(), ScreenPosition screen_position = Dialog::ScreenPosition::CenterWithinParent);
static Optional<String> get_open_filepath(Window* parent_window, const String& window_title = {}, StringView path = Core::StandardPaths::home_directory(), bool folder = false, ScreenPosition screen_position = Dialog::ScreenPosition::CenterWithinParent);
static Optional<String> get_save_filepath(Window* parent_window, const String& title, const String& extension, StringView path = Core::StandardPaths::home_directory(), ScreenPosition screen_position = Dialog::ScreenPosition::CenterWithinParent);
virtual ~FilePicker() override;
@ -43,7 +43,7 @@ private:
// ^GUI::ModelClient
virtual void model_did_update(unsigned) override;
FilePicker(Window* parent_window, Mode type = Mode::Open, const StringView& filename = "Untitled", const StringView& path = Core::StandardPaths::home_directory(), ScreenPosition screen_position = Dialog::ScreenPosition::CenterWithinParent);
FilePicker(Window* parent_window, Mode type = Mode::Open, StringView filename = "Untitled", StringView path = Core::StandardPaths::home_directory(), ScreenPosition screen_position = Dialog::ScreenPosition::CenterWithinParent);
static String ok_button_name(Mode mode)
{

View file

@ -615,7 +615,7 @@ Icon FileSystemModel::icon_for(Node const& node) const
static HashMap<String, RefPtr<Gfx::Bitmap>> s_thumbnail_cache;
static RefPtr<Gfx::Bitmap> render_thumbnail(StringView const& path)
static RefPtr<Gfx::Bitmap> render_thumbnail(StringView path)
{
auto bitmap_or_error = Gfx::Bitmap::try_load_from_file(path);
if (bitmap_or_error.is_error())
@ -760,7 +760,7 @@ void FileSystemModel::set_data(ModelIndex const& index, Variant const& data)
on_rename_successful(node.full_path(), new_full_path);
}
Vector<ModelIndex> FileSystemModel::matches(StringView const& searching, unsigned flags, ModelIndex const& index)
Vector<ModelIndex> FileSystemModel::matches(StringView searching, unsigned flags, ModelIndex const& index)
{
Node& node = const_cast<Node&>(this->node(index));
node.reify_if_needed();

View file

@ -133,7 +133,7 @@ public:
virtual bool is_editable(ModelIndex const&) const override;
virtual bool is_searchable() const override { return true; }
virtual void set_data(ModelIndex const&, Variant const&) override;
virtual Vector<ModelIndex> matches(StringView const&, unsigned = MatchesFlag::AllMatching, ModelIndex const& = ModelIndex()) override;
virtual Vector<ModelIndex> matches(StringView, unsigned = MatchesFlag::AllMatching, ModelIndex const& = ModelIndex()) override;
virtual void invalidate() override;
static String timestamp_string(time_t timestamp)

View file

@ -79,7 +79,7 @@ void FilteringProxyModel::filter()
add_matching(parent_index);
}
void FilteringProxyModel::set_filter_term(StringView const& term)
void FilteringProxyModel::set_filter_term(StringView term)
{
if (m_filter_term == term)
return;
@ -104,7 +104,7 @@ bool FilteringProxyModel::is_searchable() const
return m_model.is_searchable();
}
Vector<ModelIndex> FilteringProxyModel::matches(StringView const& searching, unsigned flags, ModelIndex const& index)
Vector<ModelIndex> FilteringProxyModel::matches(StringView searching, unsigned flags, ModelIndex const& index)
{
auto found_indices = m_model.matches(searching, flags, index);
for (size_t i = 0; i < found_indices.size(); i++)

View file

@ -29,9 +29,9 @@ public:
virtual void invalidate() override;
virtual ModelIndex index(int row, int column = 0, ModelIndex const& parent = ModelIndex()) const override;
virtual bool is_searchable() const override;
virtual Vector<ModelIndex> matches(StringView const&, unsigned = MatchesFlag::AllMatching, ModelIndex const& = ModelIndex()) override;
virtual Vector<ModelIndex> matches(StringView, unsigned = MatchesFlag::AllMatching, ModelIndex const& = ModelIndex()) override;
void set_filter_term(StringView const& term);
void set_filter_term(StringView term);
ModelIndex map(ModelIndex const&) const;

View file

@ -16,7 +16,7 @@ public:
virtual ~GMLAutocompleteProvider() override { }
private:
static bool can_have_declared_layout(const StringView& class_name)
static bool can_have_declared_layout(StringView class_name)
{
return class_name.is_one_of("GUI::Widget", "GUI::Frame");
}

View file

@ -86,7 +86,7 @@ static String format_gml_object(const JsonObject& node, size_t indentation = 0,
return builder.to_string();
}
String format_gml(const StringView& string)
String format_gml(StringView string)
{
// FIXME: Preserve comments somehow, they're not contained
// in the JSON object returned by parse_gml()

View file

@ -10,6 +10,6 @@
namespace GUI {
String format_gml(const StringView&);
String format_gml(StringView);
}

View file

@ -10,7 +10,7 @@
namespace GUI {
GMLLexer::GMLLexer(StringView const& input)
GMLLexer::GMLLexer(StringView input)
: m_input(input)
{
}

View file

@ -53,7 +53,7 @@ struct GMLToken {
class GMLLexer {
public:
GMLLexer(StringView const&);
GMLLexer(StringView);
Vector<GMLToken> lex();

View file

@ -121,7 +121,7 @@ static Optional<JsonValue> parse_core_object(Queue<GMLToken>& tokens)
return object;
}
JsonValue parse_gml(const StringView& string)
JsonValue parse_gml(StringView string)
{
auto lexer = GMLLexer(string);

View file

@ -10,6 +10,6 @@
namespace GUI {
JsonValue parse_gml(const StringView&);
JsonValue parse_gml(StringView);
}

View file

@ -14,7 +14,7 @@ REGISTER_WIDGET(GUI, GroupBox)
namespace GUI {
GroupBox::GroupBox(const StringView& title)
GroupBox::GroupBox(StringView title)
: m_title(title)
{
REGISTER_STRING_PROPERTY("title", title, set_title);
@ -58,7 +58,7 @@ void GroupBox::fonts_change_event(FontsChangeEvent& event)
invalidate_layout();
}
void GroupBox::set_title(const StringView& title)
void GroupBox::set_title(StringView title)
{
if (m_title == title)
return;

View file

@ -16,11 +16,11 @@ public:
virtual ~GroupBox() override;
String title() const { return m_title; }
void set_title(const StringView&);
void set_title(StringView);
virtual Margins content_margins() const override;
protected:
explicit GroupBox(const StringView& title = {});
explicit GroupBox(StringView title = {});
virtual void paint_event(PaintEvent&) override;
virtual void fonts_change_event(FontsChangeEvent&) override;

View file

@ -10,7 +10,7 @@
namespace GUI {
IniLexer::IniLexer(StringView const& input)
IniLexer::IniLexer(StringView input)
: m_input(input)
{
}

View file

@ -52,7 +52,7 @@ struct IniToken {
class IniLexer {
public:
IniLexer(StringView const&);
IniLexer(StringView);
Vector<IniToken> lex();

View file

@ -72,7 +72,7 @@ void IconImpl::set_bitmap_for_size(int size, RefPtr<Gfx::Bitmap>&& bitmap)
m_bitmaps.set(size, move(bitmap));
}
Icon Icon::default_icon(const StringView& name)
Icon Icon::default_icon(StringView name)
{
RefPtr<Gfx::Bitmap> bitmap16;
RefPtr<Gfx::Bitmap> bitmap32;

View file

@ -43,7 +43,7 @@ public:
Icon(const Icon&);
~Icon() { }
static Icon default_icon(const StringView&);
static Icon default_icon(StringView);
Icon& operator=(const Icon& other)
{

View file

@ -14,7 +14,7 @@ REGISTER_WIDGET(GUI, ImageWidget)
namespace GUI {
ImageWidget::ImageWidget(const StringView&)
ImageWidget::ImageWidget(StringView)
: m_timer(Core::Timer::construct())
{
@ -71,7 +71,7 @@ void ImageWidget::animate()
}
}
void ImageWidget::load_from_file(const StringView& path)
void ImageWidget::load_from_file(StringView path)
{
auto file_or_error = MappedFile::map(path);
if (file_or_error.is_error())

View file

@ -26,7 +26,7 @@ public:
bool auto_resize() const { return m_auto_resize; }
void animate();
void load_from_file(const StringView&);
void load_from_file(StringView);
int opacity_percent() const { return m_opacity_percent; }
void set_opacity_percent(int percent);
@ -34,7 +34,7 @@ public:
Function<void()> on_click;
protected:
explicit ImageWidget(const StringView& text = {});
explicit ImageWidget(StringView text = {});
virtual void mousedown_event(GUI::MouseEvent&) override;
virtual void paint_event(PaintEvent&) override;

View file

@ -14,7 +14,7 @@
namespace GUI {
InputBox::InputBox(Window* parent_window, String& text_value, StringView const& prompt, StringView const& title, StringView const& placeholder, InputType input_type)
InputBox::InputBox(Window* parent_window, String& text_value, StringView prompt, StringView title, StringView placeholder, InputType input_type)
: Dialog(parent_window)
, m_text_value(text_value)
, m_prompt(prompt)
@ -28,7 +28,7 @@ InputBox::~InputBox()
{
}
int InputBox::show(Window* parent_window, String& text_value, StringView const& prompt, StringView const& title, StringView const& placeholder, InputType input_type)
int InputBox::show(Window* parent_window, String& text_value, StringView prompt, StringView title, StringView placeholder, InputType input_type)
{
auto box = InputBox::construct(parent_window, text_value, prompt, title, placeholder, input_type);
box->set_resizable(false);

View file

@ -21,10 +21,10 @@ class InputBox : public Dialog {
public:
virtual ~InputBox() override;
static int show(Window* parent_window, String& text_value, StringView const& prompt, StringView const& title, StringView const& placeholder = {}, InputType input_type = InputType::Text);
static int show(Window* parent_window, String& text_value, StringView prompt, StringView title, StringView placeholder = {}, InputType input_type = InputType::Text);
private:
explicit InputBox(Window* parent_window, String& text_value, StringView const& prompt, StringView const& title, StringView const& placeholder, InputType input_type);
explicit InputBox(Window* parent_window, String& text_value, StringView prompt, StringView title, StringView placeholder, InputType input_type);
String text_value() const { return m_text_value; }

View file

@ -78,7 +78,7 @@ public:
}
virtual bool is_searchable() const override { return true; }
virtual Vector<GUI::ModelIndex> matches(StringView const& searching, unsigned flags, GUI::ModelIndex const&) override
virtual Vector<GUI::ModelIndex> matches(StringView searching, unsigned flags, GUI::ModelIndex const&) override
{
Vector<GUI::ModelIndex> found_indices;
if constexpr (IsTwoDimensional) {

View file

@ -13,7 +13,7 @@
namespace GUI {
int MessageBox::show(Window* parent_window, const StringView& text, const StringView& title, Type type, InputType input_type)
int MessageBox::show(Window* parent_window, StringView text, StringView title, Type type, InputType input_type)
{
auto box = MessageBox::construct(parent_window, text, title, type, input_type);
if (parent_window)
@ -21,12 +21,12 @@ int MessageBox::show(Window* parent_window, const StringView& text, const String
return box->exec();
}
int MessageBox::show_error(Window* parent_window, const StringView& text)
int MessageBox::show_error(Window* parent_window, StringView text)
{
return show(parent_window, text, "Error", GUI::MessageBox::Type::Error, GUI::MessageBox::InputType::OK);
}
MessageBox::MessageBox(Window* parent_window, const StringView& text, const StringView& title, Type type, InputType input_type)
MessageBox::MessageBox(Window* parent_window, StringView text, StringView title, Type type, InputType input_type)
: Dialog(parent_window)
, m_text(text)
, m_type(type)

View file

@ -30,11 +30,11 @@ public:
virtual ~MessageBox() override;
static int show(Window* parent_window, const StringView& text, const StringView& title, Type type = Type::None, InputType input_type = InputType::OK);
static int show_error(Window* parent_window, const StringView& text);
static int show(Window* parent_window, StringView text, StringView title, Type type = Type::None, InputType input_type = InputType::OK);
static int show_error(Window* parent_window, StringView text);
private:
explicit MessageBox(Window* parent_window, const StringView& text, const StringView& title, Type type = Type::None, InputType input_type = InputType::OK);
explicit MessageBox(Window* parent_window, StringView text, StringView title, Type type = Type::None, InputType input_type = InputType::OK);
bool should_include_ok_button() const;
bool should_include_cancel_button() const;

View file

@ -75,7 +75,7 @@ public:
virtual void set_data(ModelIndex const&, Variant const&) { }
virtual int tree_column() const { return 0; }
virtual bool accepts_drag(ModelIndex const&, Vector<String> const& mime_types) const;
virtual Vector<ModelIndex> matches(StringView const&, unsigned = MatchesFlag::AllMatching, ModelIndex const& = ModelIndex()) { return {}; }
virtual Vector<ModelIndex> matches(StringView, unsigned = MatchesFlag::AllMatching, ModelIndex const& = ModelIndex()) { return {}; }
virtual bool is_column_sortable([[maybe_unused]] int column_index) const { return true; }
virtual void sort([[maybe_unused]] int column, SortOrder) { }
@ -104,7 +104,7 @@ protected:
void for_each_client(Function<void(ModelClient&)>);
void did_update(unsigned flags = UpdateFlag::InvalidateAllIndices);
static bool string_matches(StringView const& str, StringView const& needle, unsigned flags)
static bool string_matches(StringView str, StringView needle, unsigned flags)
{
auto case_sensitivity = (flags & CaseInsensitive) ? CaseSensitivity::CaseInsensitive : CaseSensitivity::CaseSensitive;
if (flags & MatchFull)

View file

@ -14,7 +14,7 @@
namespace GUI {
ProcessChooser::ProcessChooser(const StringView& window_title, const StringView& button_label, const Gfx::Bitmap* window_icon, GUI::Window* parent_window)
ProcessChooser::ProcessChooser(StringView window_title, StringView button_label, const Gfx::Bitmap* window_icon, GUI::Window* parent_window)
: Dialog(parent_window)
, m_window_title(window_title)
, m_button_label(button_label)

View file

@ -21,7 +21,7 @@ public:
pid_t pid() const { return m_pid; }
private:
ProcessChooser(const StringView& window_title = "Process Chooser", const StringView& button_label = "Select", const Gfx::Bitmap* window_icon = nullptr, GUI::Window* parent_window = nullptr);
ProcessChooser(StringView window_title = "Process Chooser", StringView button_label = "Select", const Gfx::Bitmap* window_icon = nullptr, GUI::Window* parent_window = nullptr);
void set_pid_from_index_and_close(const ModelIndex&);

View file

@ -288,7 +288,7 @@ bool SortingProxyModel::is_searchable() const
return source().is_searchable();
}
Vector<ModelIndex> SortingProxyModel::matches(StringView const& searching, unsigned flags, ModelIndex const& proxy_index)
Vector<ModelIndex> SortingProxyModel::matches(StringView searching, unsigned flags, ModelIndex const& proxy_index)
{
auto found_indices = source().matches(searching, flags, map_to_source(proxy_index));
for (size_t i = 0; i < found_indices.size(); i++)

View file

@ -28,7 +28,7 @@ public:
virtual bool is_editable(ModelIndex const&) const override;
virtual bool is_searchable() const override;
virtual void set_data(ModelIndex const&, Variant const&) override;
virtual Vector<ModelIndex> matches(StringView const&, unsigned = MatchesFlag::AllMatching, ModelIndex const& = ModelIndex()) override;
virtual Vector<ModelIndex> matches(StringView, unsigned = MatchesFlag::AllMatching, ModelIndex const& = ModelIndex()) override;
virtual bool accepts_drag(ModelIndex const&, Vector<String> const& mime_types) const override;
virtual bool is_column_sortable(int column_index) const override;

View file

@ -44,7 +44,7 @@ TabWidget::~TabWidget()
{
}
void TabWidget::add_widget(const StringView& title, Widget& widget)
void TabWidget::add_widget(StringView title, Widget& widget)
{
m_tabs.append({ title, nullptr, &widget });
add_child(widget);
@ -537,7 +537,7 @@ Optional<size_t> TabWidget::active_tab_index() const
return {};
}
void TabWidget::set_tab_title(Widget& tab, const StringView& title)
void TabWidget::set_tab_title(Widget& tab, StringView title)
{
for (auto& t : m_tabs) {
if (t.widget == &tab) {

View file

@ -36,11 +36,11 @@ public:
GUI::Margins const& container_margins() const { return m_container_margins; }
void set_container_margins(GUI::Margins const&);
void add_widget(const StringView&, Widget&);
void add_widget(StringView, Widget&);
void remove_widget(Widget&);
template<class T, class... Args>
T& add_tab(const StringView& title, Args&&... args)
T& add_tab(StringView title, Args&&... args)
{
auto t = T::construct(forward<Args>(args)...);
add_widget(title, *t);
@ -50,7 +50,7 @@ public:
void remove_tab(Widget& tab) { remove_widget(tab); }
void remove_all_tabs_except(Widget& tab);
void set_tab_title(Widget& tab, const StringView& title);
void set_tab_title(Widget& tab, StringView title);
void set_tab_icon(Widget& tab, const Gfx::Bitmap*);
void activate_next_tab();

View file

@ -39,7 +39,7 @@ TextDocument::~TextDocument()
{
}
bool TextDocument::set_text(const StringView& text, AllowCallback allow_callback)
bool TextDocument::set_text(StringView text, AllowCallback allow_callback)
{
m_client_notifications_enabled = false;
m_undo_stack.clear();
@ -161,7 +161,7 @@ TextDocumentLine::TextDocumentLine(TextDocument& document)
clear(document);
}
TextDocumentLine::TextDocumentLine(TextDocument& document, const StringView& text)
TextDocumentLine::TextDocumentLine(TextDocument& document, StringView text)
{
set_text(document, text);
}
@ -178,7 +178,7 @@ void TextDocumentLine::set_text(TextDocument& document, const Vector<u32> text)
document.update_views({});
}
bool TextDocumentLine::set_text(TextDocument& document, const StringView& text)
bool TextDocumentLine::set_text(TextDocument& document, StringView text)
{
if (text.is_empty()) {
clear(document);
@ -403,7 +403,7 @@ TextPosition TextDocument::previous_position_before(const TextPosition& position
return { position.line(), position.column() - 1 };
}
void TextDocument::update_regex_matches(const StringView& needle)
void TextDocument::update_regex_matches(StringView needle)
{
if (m_regex_needs_update || needle != m_regex_needle) {
Regex<PosixExtended> re(needle);
@ -421,7 +421,7 @@ void TextDocument::update_regex_matches(const StringView& needle)
}
}
TextRange TextDocument::find_next(const StringView& needle, const TextPosition& start, SearchShouldWrap should_wrap, bool regmatch, bool match_case)
TextRange TextDocument::find_next(StringView needle, const TextPosition& start, SearchShouldWrap should_wrap, bool regmatch, bool match_case)
{
if (needle.is_empty())
return {};
@ -501,7 +501,7 @@ TextRange TextDocument::find_next(const StringView& needle, const TextPosition&
return {};
}
TextRange TextDocument::find_previous(const StringView& needle, const TextPosition& start, SearchShouldWrap should_wrap, bool regmatch, bool match_case)
TextRange TextDocument::find_previous(StringView needle, const TextPosition& start, SearchShouldWrap should_wrap, bool regmatch, bool match_case)
{
if (needle.is_empty())
return {};
@ -585,7 +585,7 @@ TextRange TextDocument::find_previous(const StringView& needle, const TextPositi
return {};
}
Vector<TextRange> TextDocument::find_all(const StringView& needle, bool regmatch)
Vector<TextRange> TextDocument::find_all(StringView needle, bool regmatch)
{
Vector<TextRange> ranges;
@ -889,7 +889,7 @@ void RemoveTextCommand::undo()
m_document.set_all_cursors(new_cursor);
}
TextPosition TextDocument::insert_at(const TextPosition& position, const StringView& text, const Client* client)
TextPosition TextDocument::insert_at(const TextPosition& position, StringView text, const Client* client)
{
TextPosition cursor = position;
Utf8View utf8_view(text);

View file

@ -63,7 +63,7 @@ public:
void set_spans(Vector<TextDocumentSpan> spans) { m_spans = move(spans); }
bool set_text(const StringView&, AllowCallback = AllowCallback::Yes);
bool set_text(StringView, AllowCallback = AllowCallback::Yes);
const NonnullOwnPtrVector<TextDocumentLine>& lines() const { return m_lines; }
NonnullOwnPtrVector<TextDocumentLine>& lines() { return m_lines; }
@ -88,11 +88,11 @@ public:
String text() const;
String text_in_range(const TextRange&) const;
Vector<TextRange> find_all(const StringView& needle, bool regmatch = false);
Vector<TextRange> find_all(StringView needle, bool regmatch = false);
void update_regex_matches(const StringView&);
TextRange find_next(const StringView&, const TextPosition& start = {}, SearchShouldWrap = SearchShouldWrap::Yes, bool regmatch = false, bool match_case = true);
TextRange find_previous(const StringView&, const TextPosition& start = {}, SearchShouldWrap = SearchShouldWrap::Yes, bool regmatch = false, bool match_case = true);
void update_regex_matches(StringView);
TextRange find_next(StringView, const TextPosition& start = {}, SearchShouldWrap = SearchShouldWrap::Yes, bool regmatch = false, bool match_case = true);
TextRange find_previous(StringView, const TextPosition& start = {}, SearchShouldWrap = SearchShouldWrap::Yes, bool regmatch = false, bool match_case = true);
TextPosition next_position_after(const TextPosition&, SearchShouldWrap = SearchShouldWrap::Yes) const;
TextPosition previous_position_before(const TextPosition&, SearchShouldWrap = SearchShouldWrap::Yes) const;
@ -122,7 +122,7 @@ public:
void set_all_cursors(const TextPosition&);
TextPosition insert_at(const TextPosition&, u32, const Client* = nullptr);
TextPosition insert_at(const TextPosition&, const StringView&, const Client* = nullptr);
TextPosition insert_at(const TextPosition&, StringView, const Client* = nullptr);
void remove(const TextRange&);
virtual bool is_code_document() const { return false; }
@ -154,14 +154,14 @@ private:
class TextDocumentLine {
public:
explicit TextDocumentLine(TextDocument&);
explicit TextDocumentLine(TextDocument&, const StringView&);
explicit TextDocumentLine(TextDocument&, StringView);
String to_utf8() const;
Utf32View view() const { return { code_points(), length() }; }
const u32* code_points() const { return m_text.data(); }
size_t length() const { return m_text.size(); }
bool set_text(TextDocument&, const StringView&);
bool set_text(TextDocument&, StringView);
void set_text(TextDocument&, Vector<u32>);
void append(TextDocument&, u32);
void prepend(TextDocument&, u32);

View file

@ -101,7 +101,7 @@ void TextEditor::create_actions()
m_select_all_action = CommonActions::make_select_all_action([this](auto&) { select_all(); }, this);
}
void TextEditor::set_text(StringView const& text, AllowCallback allow_callback)
void TextEditor::set_text(StringView text, AllowCallback allow_callback)
{
m_selection.clear();
@ -1378,7 +1378,7 @@ void TextEditor::delete_text_range(TextRange range)
update();
}
void TextEditor::insert_at_cursor_or_replace_selection(StringView const& text)
void TextEditor::insert_at_cursor_or_replace_selection(StringView text)
{
ReflowDeferrer defer(*this);
VERIFY(is_editable());

View file

@ -57,7 +57,7 @@ public:
virtual void set_document(TextDocument&);
String const& placeholder() const { return m_placeholder; }
void set_placeholder(StringView const& placeholder) { m_placeholder = placeholder; }
void set_placeholder(StringView placeholder) { m_placeholder = placeholder; }
TextDocumentLine& current_line() { return line(m_cursor.line()); }
TextDocumentLine const& current_line() const { return line(m_cursor.line()); }
@ -108,7 +108,7 @@ public:
Function<void()> on_focusin;
Function<void()> on_focusout;
void set_text(StringView const&, AllowCallback = AllowCallback::Yes);
void set_text(StringView, AllowCallback = AllowCallback::Yes);
void scroll_cursor_into_view();
void scroll_position_into_view(TextPosition const&);
size_t line_count() const { return document().line_count(); }
@ -121,7 +121,7 @@ public:
TextPosition cursor() const { return m_cursor; }
TextRange normalized_selection() const { return m_selection.normalized(); }
void insert_at_cursor_or_replace_selection(StringView const&);
void insert_at_cursor_or_replace_selection(StringView);
bool write_to_file(String const& path);
bool write_to_file_and_close(int fd);
bool has_selection() const { return m_selection.is_valid(); }

View file

@ -163,7 +163,7 @@ Variant::Variant(const FlyString& value)
{
}
Variant::Variant(const StringView& value)
Variant::Variant(StringView value)
: Variant(value.to_string())
{
}

View file

@ -24,7 +24,7 @@ public:
Variant(u32);
Variant(u64);
Variant(const char*);
Variant(const StringView&);
Variant(StringView);
Variant(const String&);
Variant(const FlyString&);
Variant(const Gfx::Bitmap&);

View file

@ -1055,7 +1055,7 @@ void Widget::set_override_cursor(AK::Variant<Gfx::StandardCursor, NonnullRefPtr<
}
}
bool Widget::load_from_gml(const StringView& gml_string)
bool Widget::load_from_gml(StringView gml_string)
{
return load_from_gml(gml_string, [](const String& class_name) -> RefPtr<Core::Object> {
dbgln("Class '{}' not registered", class_name);
@ -1063,7 +1063,7 @@ bool Widget::load_from_gml(const StringView& gml_string)
});
}
bool Widget::load_from_gml(const StringView& gml_string, RefPtr<Core::Object> (*unregistered_child_handler)(const String&))
bool Widget::load_from_gml(StringView gml_string, RefPtr<Core::Object> (*unregistered_child_handler)(const String&))
{
auto value = parse_gml(gml_string);
if (!value.is_object())

Some files were not shown because too many files have changed in this diff Show more