mirror of
https://github.com/RGBCube/serenity
synced 2025-07-28 07:07:44 +00:00
Everywhere: Pass AK::StringView by value
This commit is contained in:
parent
ad5d217e76
commit
8b1108e485
392 changed files with 978 additions and 978 deletions
|
@ -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) {
|
||||
|
|
|
@ -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&&);
|
||||
|
||||
|
|
|
@ -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));
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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())
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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()) {
|
||||
|
|
|
@ -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>&&);
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue