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

@ -28,7 +28,7 @@ class BookmarkEditor final : public GUI::Dialog {
public:
static Vector<JsonValue>
edit_bookmark(Window* parent_window, const StringView& title, const StringView& url)
edit_bookmark(Window* parent_window, StringView title, StringView url)
{
auto editor = BookmarkEditor::construct(parent_window, title, url);
editor->set_title("Edit Bookmark");
@ -41,7 +41,7 @@ public:
}
private:
BookmarkEditor(Window* parent_window, const StringView& title, const StringView& url)
BookmarkEditor(Window* parent_window, StringView title, StringView url)
: Dialog(parent_window)
{
auto& widget = set_main_widget<GUI::Widget>();

View file

@ -123,7 +123,7 @@ void ConsoleWidget::handle_console_messages(i32 start_index, const Vector<String
request_console_messages();
}
void ConsoleWidget::print_source_line(const StringView& source)
void ConsoleWidget::print_source_line(StringView source)
{
StringBuilder html;
html.append("<span class=\"repl-indicator\">");
@ -135,7 +135,7 @@ void ConsoleWidget::print_source_line(const StringView& source)
print_html(html.string_view());
}
void ConsoleWidget::print_html(StringView const& line)
void ConsoleWidget::print_html(StringView line)
{
StringBuilder builder;
builder.append(R"~~~(

View file

@ -21,8 +21,8 @@ public:
void notify_about_new_console_message(i32 message_index);
void handle_console_messages(i32 start_index, Vector<String> const& message_types, Vector<String> const& messages);
void print_source_line(const StringView&);
void print_html(const StringView&);
void print_source_line(StringView);
void print_html(StringView);
void reset();
Function<void(const String&)> on_js_input;

View file

@ -405,7 +405,7 @@ bool DirectoryView::open(String const& path)
return true;
}
void DirectoryView::set_status_message(StringView const& message)
void DirectoryView::set_status_message(StringView message)
{
if (on_status_message)
on_status_message(message);

View file

@ -66,10 +66,10 @@ public:
void launch(URL const&, LauncherHandler const&) const;
Function<void(StringView const& path, bool can_read_in_path, bool can_write_in_path)> on_path_change;
Function<void(StringView path, bool can_read_in_path, bool can_write_in_path)> on_path_change;
Function<void(GUI::AbstractView&)> on_selection_change;
Function<void(GUI::ModelIndex const&, GUI::ContextMenuEvent const&)> on_context_menu_request;
Function<void(StringView const&)> on_status_message;
Function<void(StringView)> on_status_message;
Function<void(int done, int total)> on_thumbnail_progress;
Function<void()> on_accepted_drop;
@ -156,7 +156,7 @@ private:
void handle_activation(GUI::ModelIndex const&);
void set_status_message(StringView const&);
void set_status_message(StringView);
void update_statusbar();
Mode m_mode { Mode::Normal };

View file

@ -115,7 +115,7 @@ void FileOperationProgressWidget::did_finish()
window()->close();
}
void FileOperationProgressWidget::did_error(StringView const& message)
void FileOperationProgressWidget::did_error(StringView message)
{
// FIXME: Communicate more with the user about errors.
close_pipe();
@ -157,7 +157,7 @@ String FileOperationProgressWidget::estimate_time(off_t bytes_done, off_t total_
return String::formatted("{} hours and {} minutes", hours_remaining, minutes_remaining);
}
void FileOperationProgressWidget::did_progress(off_t bytes_done, off_t total_byte_count, size_t files_done, size_t total_file_count, [[maybe_unused]] off_t current_file_done, [[maybe_unused]] off_t current_file_size, StringView const& current_filename)
void FileOperationProgressWidget::did_progress(off_t bytes_done, off_t total_byte_count, size_t files_done, size_t total_file_count, [[maybe_unused]] off_t current_file_done, [[maybe_unused]] off_t current_file_size, StringView current_filename)
{
auto& files_copied_label = *find_descendant_of_type_named<GUI::Label>("files_copied_label");
auto& current_file_label = *find_descendant_of_type_named<GUI::Label>("current_file_label");

View file

@ -22,8 +22,8 @@ private:
FileOperationProgressWidget(FileOperation, NonnullRefPtr<Core::File> helper_pipe);
void did_finish();
void did_error(StringView const& message);
void did_progress(off_t bytes_done, off_t total_byte_count, size_t files_done, size_t total_file_count, off_t current_file_done, off_t current_file_size, StringView const& current_filename);
void did_error(StringView message);
void did_progress(off_t bytes_done, off_t total_byte_count, size_t files_done, size_t total_file_count, off_t current_file_done, off_t current_file_size, StringView current_filename);
void close_pipe();

View file

@ -1020,7 +1020,7 @@ int run_in_windowed_mode(String initial_location, String entry_focused_on_init)
refresh_tree_view();
};
directory_view.on_status_message = [&](StringView const& message) {
directory_view.on_status_message = [&](StringView message) {
statusbar.set_text(message);
};

View file

@ -6,7 +6,7 @@
#include "History.h"
void History::push(const StringView& history_item)
void History::push(StringView history_item)
{
if (!m_items.is_empty() && m_items[m_current_history_item] == history_item)
return;

View file

@ -11,7 +11,7 @@
class History final {
public:
void push(const StringView& history_item);
void push(StringView history_item);
String current();
void go_back();

View file

@ -31,7 +31,7 @@ ManualModel::ManualModel()
m_page_icon.set_bitmap_for_size(16, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/filetype-unknown.png").release_value_but_fixme_should_propagate_errors());
}
Optional<GUI::ModelIndex> ManualModel::index_from_path(const StringView& path) const
Optional<GUI::ModelIndex> ManualModel::index_from_path(StringView path) const
{
for (int section = 0; section < row_count(); ++section) {
auto parent_index = index(section, 0);

View file

@ -21,7 +21,7 @@ public:
virtual ~ManualModel() override {};
Optional<GUI::ModelIndex> index_from_path(const StringView&) const;
Optional<GUI::ModelIndex> index_from_path(StringView) const;
String page_path(const GUI::ModelIndex&) const;
String page_and_section(const GUI::ModelIndex&) const;

View file

@ -14,7 +14,7 @@ class ManualPageNode : public ManualNode {
public:
virtual ~ManualPageNode() override { }
ManualPageNode(const ManualSectionNode& section, const StringView& page)
ManualPageNode(const ManualSectionNode& section, StringView page)
: m_section(section)
, m_page(page)
{

View file

@ -324,7 +324,7 @@ void HexEditorWidget::initialize_menubar(GUI::Window& window)
help_menu.add_action(GUI::CommonActions::make_about_action("Hex Editor", GUI::Icon::default_icon("app-hex-editor"), &window));
}
void HexEditorWidget::set_path(StringView const& path)
void HexEditorWidget::set_path(StringView path)
{
if (path.is_empty()) {
m_path = {};

View file

@ -28,7 +28,7 @@ public:
private:
HexEditorWidget();
void set_path(StringView const&);
void set_path(StringView);
void update_title();
void set_search_results_visible(bool visible);

View file

@ -164,7 +164,7 @@ void KeyboardMapperWidget::save()
save_to_file(m_filename);
}
void KeyboardMapperWidget::save_to_file(const StringView& filename)
void KeyboardMapperWidget::save_to_file(StringView filename)
{
JsonObject map_json;

View file

@ -20,7 +20,7 @@ public:
void load_from_file(const String);
void load_from_system();
void save();
void save_to_file(const StringView&);
void save_to_file(StringView);
protected:
virtual void keydown_event(GUI::KeyEvent&) override;

View file

@ -123,7 +123,7 @@ void Track::reset()
m_roll_iterators[note] = m_roll_notes[note].begin();
}
String Track::set_recorded_sample(const StringView& path)
String Track::set_recorded_sample(StringView path)
{
NonnullRefPtr<Audio::Loader> loader = Audio::Loader::create(path);
if (loader->has_error())

View file

@ -36,7 +36,7 @@ public:
void fill_sample(Sample& sample);
void reset();
String set_recorded_sample(const StringView& path);
String set_recorded_sample(StringView path);
void set_note(int note, Switch);
void set_roll_note(int note, u32 on_sample, u32 off_sample);
void set_wave(int wave);

View file

@ -51,7 +51,7 @@ ToolboxWidget::~ToolboxWidget()
void ToolboxWidget::setup_tools()
{
auto add_tool = [&](String name, StringView const& icon_name, GUI::Shortcut const& shortcut, NonnullOwnPtr<Tool> tool) {
auto add_tool = [&](String name, StringView icon_name, GUI::Shortcut const& shortcut, NonnullOwnPtr<Tool> tool) {
auto action = GUI::Action::create_checkable(move(name), shortcut, Gfx::Bitmap::try_load_from_file(String::formatted("/res/icons/pixelpaint/{}.png", icon_name)).release_value_but_fixme_should_propagate_errors(),
[this, tool = tool.ptr()](auto& action) {
if (action.is_checked()) {

View file

@ -46,7 +46,7 @@ void Cell::set_type(const CellType* type)
m_type = type;
}
void Cell::set_type(const StringView& name)
void Cell::set_type(StringView name)
{
auto* cell_type = CellType::get_by_name(name);
if (cell_type) {

View file

@ -57,7 +57,7 @@ struct Cell : public Weakable<Cell> {
Kind kind() const { return m_kind; }
const Vector<WeakPtr<Cell>>& referencing_cells() const { return m_referencing_cells; }
void set_type(const StringView& name);
void set_type(StringView name);
void set_type(const CellType*);
void set_type_metadata(CellTypeMetadata&&);

View file

@ -20,7 +20,7 @@ static Spreadsheet::DateCell s_date_cell;
namespace Spreadsheet {
const CellType* CellType::get_by_name(const StringView& name)
const CellType* CellType::get_by_name(StringView name)
{
return s_cell_types.get(name).value_or(nullptr);
}
@ -33,7 +33,7 @@ Vector<StringView> CellType::names()
return names;
}
CellType::CellType(const StringView& name)
CellType::CellType(StringView name)
: m_name(name)
{
VERIFY(!s_cell_types.contains(name));

View file

@ -25,7 +25,7 @@ struct CellTypeMetadata {
class CellType {
public:
static const CellType* get_by_name(const StringView&);
static const CellType* get_by_name(StringView);
static Vector<StringView> names();
virtual String display(Cell&, const CellTypeMetadata&) const = 0;
@ -35,7 +35,7 @@ public:
const String& name() const { return m_name; }
protected:
CellType(const StringView& name);
CellType(StringView name);
private:
String m_name;

View file

@ -136,7 +136,7 @@ HelpWindow::HelpWindow(GUI::Window* parent)
};
}
String HelpWindow::render(const StringView& key)
String HelpWindow::render(StringView key)
{
VERIFY(m_docs.has_object(key));
auto& doc = m_docs.get(key).as_object();

View file

@ -32,7 +32,7 @@ public:
private:
static RefPtr<HelpWindow> s_the;
String render(const StringView& key);
String render(StringView key);
HelpWindow(GUI::Window* parent = nullptr);
JsonObject m_docs;

View file

@ -24,7 +24,7 @@
namespace Spreadsheet {
Sheet::Sheet(const StringView& name, Workbook& workbook)
Sheet::Sheet(StringView name, Workbook& workbook)
: Sheet(workbook)
{
m_name = name;
@ -156,7 +156,7 @@ void Sheet::update(Cell& cell)
}
}
Sheet::ValueAndException Sheet::evaluate(const StringView& source, Cell* on_behalf_of)
Sheet::ValueAndException Sheet::evaluate(StringView source, Cell* on_behalf_of)
{
TemporaryChange cell_change { m_current_cell_being_evaluated, on_behalf_of };
ScopeGuard clear_exception { [&] { interpreter().vm().clear_exception(); } };
@ -181,7 +181,7 @@ Sheet::ValueAndException Sheet::evaluate(const StringView& source, Cell* on_beha
return { value, {} };
}
Cell* Sheet::at(const StringView& name)
Cell* Sheet::at(StringView name)
{
auto pos = parse_cell_name(name);
if (pos.has_value())
@ -200,7 +200,7 @@ Cell* Sheet::at(const Position& position)
return it->value;
}
Optional<Position> Sheet::parse_cell_name(const StringView& name) const
Optional<Position> Sheet::parse_cell_name(StringView name) const
{
GenericLexer lexer(name);
auto col = lexer.consume_while(isalpha);
@ -216,7 +216,7 @@ Optional<Position> Sheet::parse_cell_name(const StringView& name) const
return Position { it.index(), row.to_uint().value() };
}
Optional<size_t> Sheet::column_index(const StringView& column_name) const
Optional<size_t> Sheet::column_index(StringView column_name) const
{
auto maybe_index = convert_from_string(column_name);
if (!maybe_index.has_value())
@ -233,7 +233,7 @@ Optional<size_t> Sheet::column_index(const StringView& column_name) const
return index;
}
Optional<String> Sheet::column_arithmetic(const StringView& column_name, int offset)
Optional<String> Sheet::column_arithmetic(StringView column_name, int offset)
{
auto maybe_index = column_index(column_name);
if (!maybe_index.has_value())

View file

@ -31,9 +31,9 @@ public:
~Sheet();
Optional<Position> parse_cell_name(const StringView&) const;
Optional<size_t> column_index(const StringView& column_name) const;
Optional<String> column_arithmetic(const StringView& column_name, int offset);
Optional<Position> parse_cell_name(StringView) const;
Optional<size_t> column_index(StringView column_name) const;
Optional<String> column_arithmetic(StringView column_name, int offset);
Cell* from_url(const URL&);
const Cell* from_url(const URL& url) const { return const_cast<Sheet*>(this)->from_url(url); }
@ -50,7 +50,7 @@ public:
static RefPtr<Sheet> from_xsv(const Reader::XSV&, Workbook&);
const String& name() const { return m_name; }
void set_name(const StringView& name) { m_name = name; }
void set_name(StringView name) { m_name = name; }
JsonObject gather_documentation() const;
@ -62,8 +62,8 @@ public:
Cell* at(const Position& position);
const Cell* at(const Position& position) const { return const_cast<Sheet*>(this)->at(position); }
const Cell* at(const StringView& name) const { return const_cast<Sheet*>(this)->at(name); }
Cell* at(const StringView&);
const Cell* at(StringView name) const { return const_cast<Sheet*>(this)->at(name); }
Cell* at(StringView);
const Cell& ensure(const Position& position) const { return const_cast<Sheet*>(this)->ensure(position); }
Cell& ensure(const Position& position)
@ -111,7 +111,7 @@ public:
JS::Value value;
JS::Exception* exception { nullptr };
};
ValueAndException evaluate(const StringView&, Cell* = nullptr);
ValueAndException evaluate(StringView, Cell* = nullptr);
JS::Interpreter& interpreter() const;
SheetGlobalObject& global_object() const { return *m_global_object; }
@ -136,7 +136,7 @@ public:
private:
explicit Sheet(Workbook&);
explicit Sheet(const StringView& name, Workbook&);
explicit Sheet(StringView name, Workbook&);
String m_name;
Vector<String> m_columns;

View file

@ -369,14 +369,14 @@ void SpreadsheetWidget::try_generate_tip_for_input_expression(StringView source,
}
}
void SpreadsheetWidget::save(const StringView& filename)
void SpreadsheetWidget::save(StringView filename)
{
auto result = m_workbook->save(filename);
if (result.is_error())
GUI::MessageBox::show_error(window(), result.error());
}
void SpreadsheetWidget::load(const StringView& filename)
void SpreadsheetWidget::load(StringView filename)
{
auto result = m_workbook->load(filename);
if (result.is_error()) {

View file

@ -19,8 +19,8 @@ class SpreadsheetWidget final : public GUI::Widget {
public:
~SpreadsheetWidget();
void save(const StringView& filename);
void load(const StringView& filename);
void save(StringView filename);
void load(StringView filename);
bool request_close();
void add_sheet();
void add_sheet(NonnullRefPtr<Sheet>&&);

View file

@ -43,7 +43,7 @@ bool Workbook::set_filename(const String& filename)
return true;
}
Result<bool, String> Workbook::load(const StringView& filename)
Result<bool, String> Workbook::load(StringView filename)
{
auto file_or_error = Core::File::open(filename, Core::OpenMode::ReadOnly);
if (file_or_error.is_error()) {
@ -70,7 +70,7 @@ Result<bool, String> Workbook::load(const StringView& filename)
return true;
}
Result<bool, String> Workbook::save(const StringView& filename)
Result<bool, String> Workbook::save(StringView filename)
{
auto mime = Core::guess_mime_type_based_on_filename(filename);
auto file = Core::File::construct(filename);

View file

@ -17,8 +17,8 @@ class Workbook {
public:
Workbook(NonnullRefPtrVector<Sheet>&& sheets);
Result<bool, String> save(const StringView& filename);
Result<bool, String> load(const StringView& filename);
Result<bool, String> save(StringView filename);
Result<bool, String> load(StringView filename);
const String& current_filename() const { return m_current_filename; }
bool set_filename(const String& filename);
@ -30,7 +30,7 @@ public:
const NonnullRefPtrVector<Sheet>& sheets() const { return m_sheets; }
NonnullRefPtrVector<Sheet> sheets() { return m_sheets; }
Sheet& add_sheet(const StringView& name)
Sheet& add_sheet(StringView name)
{
auto sheet = Sheet::construct(name, *this);
m_sheets.append(sheet);

View file

@ -310,7 +310,7 @@ GUI::Variant ProcessModel::data(GUI::ModelIndex const& index, GUI::ModelRole rol
return {};
}
Vector<GUI::ModelIndex> ProcessModel::matches(StringView const& searching, unsigned flags, GUI::ModelIndex const&)
Vector<GUI::ModelIndex> ProcessModel::matches(StringView searching, unsigned flags, GUI::ModelIndex const&)
{
Vector<GUI::ModelIndex> found_indices;

View file

@ -61,7 +61,7 @@ public:
virtual String column_name(int column) const override;
virtual GUI::Variant data(GUI::ModelIndex const&, GUI::ModelRole) const override;
virtual bool is_searchable() const override { return true; }
virtual Vector<GUI::ModelIndex> matches(StringView const&, unsigned = MatchesFlag::AllMatching, GUI::ModelIndex const& = GUI::ModelIndex()) override;
virtual Vector<GUI::ModelIndex> matches(StringView, unsigned = MatchesFlag::AllMatching, GUI::ModelIndex const& = GUI::ModelIndex()) override;
virtual bool is_column_sortable(int column_index) const override { return column_index != Column::Icon; }
void update();

View file

@ -317,7 +317,7 @@ int main(int argc, char** argv)
terminal.on_command_exit = [&] {
app->quit(0);
};
terminal.on_title_change = [&](auto& title) {
terminal.on_title_change = [&](auto title) {
window->set_title(title);
};
terminal.on_terminal_size_change = [&](auto& size) {

View file

@ -619,7 +619,7 @@ void MainWidget::initialize_menubar(GUI::Window& window)
help_menu.add_action(GUI::CommonActions::make_about_action("Text Editor", GUI::Icon::default_icon("app-text-editor"), &window));
}
void MainWidget::set_path(StringView const& path)
void MainWidget::set_path(StringView path)
{
if (path.is_empty()) {
m_path = {};

View file

@ -44,7 +44,7 @@ public:
private:
MainWidget();
void set_path(StringView const&);
void set_path(StringView);
void update_preview();
void update_markdown_preview();
void update_html_preview();