summaryrefslogtreecommitdiff
path: root/Userland/Applications/Spreadsheet
diff options
context:
space:
mode:
authorAndreas Kling <kling@serenityos.org>2021-11-11 00:55:02 +0100
committerAndreas Kling <kling@serenityos.org>2021-11-11 01:27:46 +0100
commit8b1108e4858f797c9216dc8ae4a3918ad50c73b4 (patch)
treeca64ba25aa735d25013d76c6d83570496c742014 /Userland/Applications/Spreadsheet
parentad5d217e760c7fb73ffc0c4c827d767d6be8ec80 (diff)
downloadserenity-8b1108e4858f797c9216dc8ae4a3918ad50c73b4.zip
Everywhere: Pass AK::StringView by value
Diffstat (limited to 'Userland/Applications/Spreadsheet')
-rw-r--r--Userland/Applications/Spreadsheet/Cell.cpp2
-rw-r--r--Userland/Applications/Spreadsheet/Cell.h2
-rw-r--r--Userland/Applications/Spreadsheet/CellType/Type.cpp4
-rw-r--r--Userland/Applications/Spreadsheet/CellType/Type.h4
-rw-r--r--Userland/Applications/Spreadsheet/HelpWindow.cpp2
-rw-r--r--Userland/Applications/Spreadsheet/HelpWindow.h2
-rw-r--r--Userland/Applications/Spreadsheet/Spreadsheet.cpp12
-rw-r--r--Userland/Applications/Spreadsheet/Spreadsheet.h16
-rw-r--r--Userland/Applications/Spreadsheet/SpreadsheetWidget.cpp4
-rw-r--r--Userland/Applications/Spreadsheet/SpreadsheetWidget.h4
-rw-r--r--Userland/Applications/Spreadsheet/Workbook.cpp4
-rw-r--r--Userland/Applications/Spreadsheet/Workbook.h6
12 files changed, 31 insertions, 31 deletions
diff --git a/Userland/Applications/Spreadsheet/Cell.cpp b/Userland/Applications/Spreadsheet/Cell.cpp
index 0bdf19f127..e3bd310b42 100644
--- a/Userland/Applications/Spreadsheet/Cell.cpp
+++ b/Userland/Applications/Spreadsheet/Cell.cpp
@@ -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) {
diff --git a/Userland/Applications/Spreadsheet/Cell.h b/Userland/Applications/Spreadsheet/Cell.h
index d3d4559336..d2d3541c1a 100644
--- a/Userland/Applications/Spreadsheet/Cell.h
+++ b/Userland/Applications/Spreadsheet/Cell.h
@@ -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&&);
diff --git a/Userland/Applications/Spreadsheet/CellType/Type.cpp b/Userland/Applications/Spreadsheet/CellType/Type.cpp
index b2a9af330d..5690d8b64b 100644
--- a/Userland/Applications/Spreadsheet/CellType/Type.cpp
+++ b/Userland/Applications/Spreadsheet/CellType/Type.cpp
@@ -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));
diff --git a/Userland/Applications/Spreadsheet/CellType/Type.h b/Userland/Applications/Spreadsheet/CellType/Type.h
index 343e0e45ff..025b14650d 100644
--- a/Userland/Applications/Spreadsheet/CellType/Type.h
+++ b/Userland/Applications/Spreadsheet/CellType/Type.h
@@ -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;
diff --git a/Userland/Applications/Spreadsheet/HelpWindow.cpp b/Userland/Applications/Spreadsheet/HelpWindow.cpp
index 86772bd462..0263bc1d77 100644
--- a/Userland/Applications/Spreadsheet/HelpWindow.cpp
+++ b/Userland/Applications/Spreadsheet/HelpWindow.cpp
@@ -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();
diff --git a/Userland/Applications/Spreadsheet/HelpWindow.h b/Userland/Applications/Spreadsheet/HelpWindow.h
index d5756c81c0..a7eb245574 100644
--- a/Userland/Applications/Spreadsheet/HelpWindow.h
+++ b/Userland/Applications/Spreadsheet/HelpWindow.h
@@ -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;
diff --git a/Userland/Applications/Spreadsheet/Spreadsheet.cpp b/Userland/Applications/Spreadsheet/Spreadsheet.cpp
index 539c953d6e..88f054652b 100644
--- a/Userland/Applications/Spreadsheet/Spreadsheet.cpp
+++ b/Userland/Applications/Spreadsheet/Spreadsheet.cpp
@@ -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())
diff --git a/Userland/Applications/Spreadsheet/Spreadsheet.h b/Userland/Applications/Spreadsheet/Spreadsheet.h
index 9637e08bb0..e3f0f24e95 100644
--- a/Userland/Applications/Spreadsheet/Spreadsheet.h
+++ b/Userland/Applications/Spreadsheet/Spreadsheet.h
@@ -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;
diff --git a/Userland/Applications/Spreadsheet/SpreadsheetWidget.cpp b/Userland/Applications/Spreadsheet/SpreadsheetWidget.cpp
index e35cff4e25..93dd864494 100644
--- a/Userland/Applications/Spreadsheet/SpreadsheetWidget.cpp
+++ b/Userland/Applications/Spreadsheet/SpreadsheetWidget.cpp
@@ -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()) {
diff --git a/Userland/Applications/Spreadsheet/SpreadsheetWidget.h b/Userland/Applications/Spreadsheet/SpreadsheetWidget.h
index 9748476f10..3ec08531bb 100644
--- a/Userland/Applications/Spreadsheet/SpreadsheetWidget.h
+++ b/Userland/Applications/Spreadsheet/SpreadsheetWidget.h
@@ -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>&&);
diff --git a/Userland/Applications/Spreadsheet/Workbook.cpp b/Userland/Applications/Spreadsheet/Workbook.cpp
index df9b331d4e..65f269a209 100644
--- a/Userland/Applications/Spreadsheet/Workbook.cpp
+++ b/Userland/Applications/Spreadsheet/Workbook.cpp
@@ -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);
diff --git a/Userland/Applications/Spreadsheet/Workbook.h b/Userland/Applications/Spreadsheet/Workbook.h
index 1ed0828ef6..a2831ace4e 100644
--- a/Userland/Applications/Spreadsheet/Workbook.h
+++ b/Userland/Applications/Spreadsheet/Workbook.h
@@ -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);