diff options
author | Max Kellermann <max@duempel.org> | 2014-02-01 00:38:57 +0100 |
---|---|---|
committer | Max Kellermann <max@duempel.org> | 2014-02-01 00:38:57 +0100 |
commit | 981080500b729089fac4263839350f1d25f1d90e (patch) | |
tree | 28c34af6d4441d427da718326ac9850b4074bb1f /src/Stats.cxx | |
parent | 636d28b784def19149f502daa3f7fee182669782 (diff) |
Stats: pass Database reference around
Call GetDatabase() only once.
Diffstat (limited to 'src/Stats.cxx')
-rw-r--r-- | src/Stats.cxx | 17 |
1 files changed, 8 insertions, 9 deletions
diff --git a/src/Stats.cxx b/src/Stats.cxx index 4ff87e1d8..4051d8049 100644 --- a/src/Stats.cxx +++ b/src/Stats.cxx @@ -66,7 +66,7 @@ stats_invalidate() } static bool -stats_update() +stats_update(const Database &db) { switch (stats_validity) { case StatsValidity::INVALID: @@ -82,7 +82,7 @@ stats_update() Error error; const DatabaseSelection selection("", true); - if (GetDatabase()->GetStats(selection, stats, error)) { + if (db.GetStats(selection, stats, error)) { stats_validity = StatsValidity::VALID; return true; } else { @@ -94,11 +94,9 @@ stats_update() } static void -db_stats_print(Client &client) +db_stats_print(Client &client, const Database &db) { - assert(GetDatabase() != nullptr); - - if (!stats_update()) + if (!stats_update(db)) return; client_printf(client, @@ -111,7 +109,7 @@ db_stats_print(Client &client) stats.song_count, stats.total_duration); - const time_t update_stamp = GetDatabase()->GetUpdateStamp(); + const time_t update_stamp = db.GetUpdateStamp(); if (update_stamp > 0) client_printf(client, "db_update: %lu\n", @@ -134,7 +132,8 @@ stats_print(Client &client) (unsigned long)(client.player_control.GetTotalPlayTime() + 0.5)); #ifdef ENABLE_DATABASE - if (GetDatabase() != nullptr) - db_stats_print(client); + const Database *db = GetDatabase(); + if (db != nullptr) + db_stats_print(client, *db); #endif } |