Skip to content

Commit

Permalink
FileBrowserPage: pass std::string_view to ChangeDirectory()
Browse files Browse the repository at this point in the history
  • Loading branch information
MaxKellermann committed Jun 30, 2022
1 parent b8e252c commit e9910fe
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions src/FileBrowserPage.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ class FileBrowserPage final : public FileListPage {
* Change to the specified absolute directory.
*/
bool ChangeDirectory(struct mpdclient &c,
std::string &&new_path) noexcept;
std::string_view new_path) noexcept;

/**
* Change to the parent directory of the current directory.
Expand Down Expand Up @@ -118,9 +118,9 @@ FileBrowserPage::Reload(struct mpdclient &c) noexcept

bool
FileBrowserPage::ChangeDirectory(struct mpdclient &c,
std::string &&new_path) noexcept
std::string_view new_path) noexcept
{
current_path = std::move(new_path);
current_path = new_path;

Reload(c);

Expand All @@ -134,10 +134,9 @@ FileBrowserPage::ChangeDirectory(struct mpdclient &c,
bool
FileBrowserPage::ChangeToParent(struct mpdclient &c) noexcept
{
std::string parent{GetParentUri(current_path.c_str())};
const auto old_path = std::move(current_path);

bool success = ChangeDirectory(c, std::move(parent));
bool success = ChangeDirectory(c, GetParentUri(old_path));

int idx = success
? filelist->FindDirectory(old_path.c_str())
Expand Down Expand Up @@ -178,7 +177,7 @@ FileBrowserPage::GotoSong(struct mpdclient &c, const struct mpd_song &song) noex

/* determine the song's parent directory and go there */

if (!ChangeDirectory(c, std::string{GetParentUri(uri)}))
if (!ChangeDirectory(c, GetParentUri(uri)))
return false;

/* select the specified song */
Expand Down

0 comments on commit e9910fe

Please sign in to comment.