From be77226d6b42ec26f3884fe3e7645fac16c34baf Mon Sep 17 00:00:00 2001 From: Charles Kerr Date: Fri, 10 Mar 2023 14:32:12 -0600 Subject: [PATCH] fix: update Torrent::ratio() to match #2770 (#5193) --- qt/Torrent.h | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/qt/Torrent.h b/qt/Torrent.h index d40f76167..affbcd580 100644 --- a/qt/Torrent.h +++ b/qt/Torrent.h @@ -300,10 +300,9 @@ public: [[nodiscard]] constexpr auto ratio() const noexcept { - auto const u = uploadedEver(); - auto const d = downloadedEver(); - auto const t = totalSize(); - return double(u) / (d ? d : t); + auto const numerator = static_cast(uploadedEver()); + auto const denominator = sizeWhenDone(); + return denominator > 0U ? numerator / denominator : double{}; } [[nodiscard]] constexpr double percentComplete() const noexcept