From e2261a03fc5ab0215c87b70f836bb344dc06e913 Mon Sep 17 00:00:00 2001 From: ColinDuquesnoy Date: Sun, 27 Aug 2017 19:28:42 +0200 Subject: [PATCH] Fix potential performance issues Allow 2 seconds of imprecision for duration. This might happen when we compute duration based on position and remaining time. --- lib/MellowPlayer/Application/Player/Song.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/MellowPlayer/Application/Player/Song.cpp b/lib/MellowPlayer/Application/Player/Song.cpp index 85fabb34..fe24bf59 100644 --- a/lib/MellowPlayer/Application/Player/Song.cpp +++ b/lib/MellowPlayer/Application/Player/Song.cpp @@ -1,4 +1,5 @@ #include "Song.hpp" +#include using namespace MellowPlayer::Application; @@ -49,7 +50,7 @@ bool Song::isFavorite() const void Song::setDuration(double value) { - if (value == duration_) + if (abs(duration_ - value) < 2) return; duration_ = value;