From 52b3926f925d336692132b9162b1ac14932a5005 Mon Sep 17 00:00:00 2001 From: Christophe Dumez Date: Thu, 18 Mar 2010 23:12:25 +0000 Subject: [PATCH] Code optimization --- src/downloadedpiecesbar.h | 2 +- src/pieceavailabilitybar.h | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/downloadedpiecesbar.h b/src/downloadedpiecesbar.h index 8a5ee9d38..974eed68d 100644 --- a/src/downloadedpiecesbar.h +++ b/src/downloadedpiecesbar.h @@ -64,7 +64,7 @@ public: // Reduce the number of pieces before creating the pixmap // otherwise it can crash when there are too many pieces if(nb_pieces > width()) { - int ratio = floor(nb_pieces/(double)width()); + const int ratio = floor(nb_pieces/(double)width()); std::vector scaled_pieces; std::vector scaled_downloading; for(int i=0; i& avail) { + double setAvailability(const std::vector& avail) { double average = 0; if(avail.empty()) { // Empty bar @@ -60,12 +60,12 @@ public: pixmap = pix; } else { // Look for maximum value - int nb_pieces = avail.size(); + const int nb_pieces = avail.size(); average = std::accumulate(avail.begin(), avail.end(), 0)/(double)nb_pieces; // Reduce the number of pieces before creating the pixmap // otherwise it can crash when there are too many pieces if(nb_pieces > width()) { - int ratio = floor(nb_pieces/(double)width()); + const int ratio = floor(nb_pieces/(double)width()); std::vector scaled_avail; for(int i=0; i