Skip to content

Commit

Permalink
WalkHandler: move std::string&& to OnWalkAncient()
Browse files Browse the repository at this point in the history
Needed if the implementation wants to cull asynchronously.
  • Loading branch information
MaxKellermann committed Dec 5, 2024
1 parent 191d3bf commit 40e35cb
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/Cull.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ Cull::Start(FileDescriptor root_fd)

void
Cull::OnWalkAncient(WalkDirectory &directory,
std::string_view filename) noexcept
std::string &&filename) noexcept
{
CullFile(dev_cachefiles, directory.fd, filename);
}
Expand Down
2 changes: 1 addition & 1 deletion src/Cull.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,6 @@ private:

// virtual methods from WalkHandler
void OnWalkAncient(WalkDirectory &directory,
std::string_view filename) noexcept override;
std::string &&filename) noexcept override;
void OnWalkFinished(WalkResult &&result) noexcept override;
};
4 changes: 2 additions & 2 deletions src/WHandler.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

#pragma once

#include <string_view>
#include <string>

class FileDescriptor;
struct WalkDirectory;
Expand All @@ -20,7 +20,7 @@ public:
* unconditionally).
*/
virtual void OnWalkAncient(WalkDirectory &directory,
std::string_view filename) noexcept = 0;
std::string &&filename) noexcept = 0;

/**
* The #Walk has finished completely. This method is allowed
Expand Down
2 changes: 1 addition & 1 deletion src/Walk.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ Walk::AddFile(WalkDirectory &parent, std::string &&name,
FileTime atime, uint_least64_t size)
{
if (atime < discard_older_than) {
handler.OnWalkAncient(parent, name);
handler.OnWalkAncient(parent, std::move(name));
return;
}

Expand Down
2 changes: 1 addition & 1 deletion test/RunWalk.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ struct Instance final : WalkHandler {

// virtual methods from WalkHandler
void OnWalkAncient([[maybe_unused]] WalkDirectory &directory,
std::string_view filename) noexcept override {
std::string &&filename) noexcept override {
fmt::print("ancient {:?}\n", filename);
}

Expand Down

0 comments on commit 40e35cb

Please sign in to comment.