OSDN Git Service

svg document micro-optimization
authorIvailo Monev <xakepa10@laimg.moc>
Fri, 7 Oct 2016 23:36:37 +0000 (23:36 +0000)
committerIvailo Monev <xakepa10@laimg.moc>
Fri, 7 Oct 2016 23:36:37 +0000 (23:36 +0000)
Signed-off-by: Ivailo Monev <xakepa10@laimg.moc>
src/svg/qsvgtinydocument.cpp

index 95ea7e7..3a1c03a 100644 (file)
@@ -476,11 +476,10 @@ int QSvgTinyDocument::currentFrame() const
 
 void QSvgTinyDocument::setCurrentFrame(int frame)
 {
-    int totalFrames = m_fps * m_animationDuration;
-    double framePercentage = frame/double(totalFrames);
-    double timeForFrame = m_animationDuration * framePercentage; //in S
-    timeForFrame *= 1000; //in ms
-    int timeToAdd = int(timeForFrame - m_time.elapsed());
+    const int totalFrames = m_fps * m_animationDuration;
+    const int framePercentage = frame / totalFrames;
+    const int timeForFrame = m_animationDuration * framePercentage * 1000; //in ms
+    const int timeToAdd = timeForFrame - m_time.elapsed();
     m_time = m_time.addMSecs(timeToAdd);
 }