remove std::bind usage as much as possible

Reduces unstripped size. stripped size is the same.

Also took the time to remove using std::placeholders.

Signed-off-by: Rosen Penev <rosenp@gmail.com>
This commit is contained in:
Rosen Penev
2020-05-04 14:27:04 -07:00
parent 3c955639a7
commit e6a77e1297
11 changed files with 42 additions and 46 deletions

View File

@@ -146,16 +146,23 @@ db_selection_print(Response &r, Partition &partition,
{
const Database &db = partition.GetDatabaseOrThrow();
using namespace std::placeholders;
const auto d = selection.filter == nullptr
? std::bind(full ? PrintDirectoryFull : PrintDirectoryBrief,
std::ref(r), base, _1)
? [&,base](const auto &dir)
{ return full ?
PrintDirectoryFull(r, base, dir) :
PrintDirectoryBrief(r, base, dir); }
: VisitDirectory();
VisitSong s = std::bind(full ? PrintSongFull : PrintSongBrief,
std::ref(r), base, _1);
VisitSong s = [&,base](const auto &song)
{ return full ?
PrintSongFull(r, base, song) :
PrintSongBrief(r, base, song); };
const auto p = selection.filter == nullptr
? std::bind(full ? PrintPlaylistFull : PrintPlaylistBrief,
std::ref(r), base, _1, _2)
? [&,base](const auto &playlist, const auto &dir)
{ return full ?
PrintPlaylistFull(r, base, playlist, dir) :
PrintPlaylistBrief(r, base, playlist, dir); }
: VisitPlaylist();
db.Visit(selection, d, s, p);
@@ -175,9 +182,9 @@ PrintSongUris(Response &r, Partition &partition,
const DatabaseSelection selection("", true, filter);
using namespace std::placeholders;
const auto f = std::bind(PrintSongURIVisitor,
std::ref(r), _1);
const auto f = [&](const auto &song)
{ return PrintSongURIVisitor(r, song); };
db.Visit(selection, f);
}