mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 01:47:35 +00:00
Take StringView in more places
We should work towards a pattern where we take StringView as function arguments, and store String as member, to push the String construction to the last possible moment.
This commit is contained in:
parent
b55b6cd7fc
commit
7bce096afd
14 changed files with 28 additions and 36 deletions
|
@ -108,7 +108,7 @@ void DirectoryView::set_view_mode(ViewMode mode)
|
|||
ASSERT_NOT_REACHED();
|
||||
}
|
||||
|
||||
void DirectoryView::add_path_to_history(const String& path)
|
||||
void DirectoryView::add_path_to_history(const StringView& path)
|
||||
{
|
||||
if (m_path_history_position < m_path_history.size())
|
||||
m_path_history.resize(m_path_history_position + 1);
|
||||
|
@ -117,13 +117,13 @@ void DirectoryView::add_path_to_history(const String& path)
|
|||
m_path_history_position = m_path_history.size() - 1;
|
||||
}
|
||||
|
||||
void DirectoryView::open(const String& path)
|
||||
void DirectoryView::open(const StringView& path)
|
||||
{
|
||||
add_path_to_history(path);
|
||||
model().open(path);
|
||||
}
|
||||
|
||||
void DirectoryView::set_status_message(const String& message)
|
||||
void DirectoryView::set_status_message(const StringView& message)
|
||||
{
|
||||
if (on_status_message)
|
||||
on_status_message(message);
|
||||
|
|
|
@ -12,7 +12,7 @@ public:
|
|||
explicit DirectoryView(GWidget* parent);
|
||||
virtual ~DirectoryView() override;
|
||||
|
||||
void open(const String& path);
|
||||
void open(const StringView& path);
|
||||
String path() const { return model().path(); }
|
||||
void open_parent_directory();
|
||||
void open_previous_directory();
|
||||
|
@ -22,8 +22,8 @@ public:
|
|||
|
||||
void refresh();
|
||||
|
||||
Function<void(const String&)> on_path_change;
|
||||
Function<void(String)> on_status_message;
|
||||
Function<void(const StringView&)> on_path_change;
|
||||
Function<void(const StringView&)> on_status_message;
|
||||
Function<void(int done, int total)> on_thumbnail_progress;
|
||||
|
||||
enum ViewMode
|
||||
|
@ -41,14 +41,14 @@ private:
|
|||
|
||||
void handle_activation(const GModelIndex&);
|
||||
|
||||
void set_status_message(const String&);
|
||||
void set_status_message(const StringView&);
|
||||
|
||||
ViewMode m_view_mode { Invalid };
|
||||
|
||||
Retained<GDirectoryModel> m_model;
|
||||
int m_path_history_position { 0 };
|
||||
Vector<String> m_path_history;
|
||||
void add_path_to_history(const String& path);
|
||||
void add_path_to_history(const StringView& path);
|
||||
|
||||
GTableView* m_table_view { nullptr };
|
||||
GItemView* m_item_view { nullptr };
|
||||
|
|
|
@ -199,8 +199,8 @@ int main(int argc, char** argv)
|
|||
go_back_action->set_enabled(directory_view->path_history_position() > 0);
|
||||
};
|
||||
|
||||
directory_view->on_status_message = [statusbar] (String message) {
|
||||
statusbar->set_text(move(message));
|
||||
directory_view->on_status_message = [statusbar] (const StringView& message) {
|
||||
statusbar->set_text(message);
|
||||
};
|
||||
|
||||
directory_view->on_thumbnail_progress = [&] (int done, int total) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue