From 67973515d5bb19a6a8daf5ddd428839ffdc6933a Mon Sep 17 00:00:00 2001 From: Christophe Dumez Date: Mon, 11 Oct 2010 21:06:53 +0000 Subject: [PATCH] Performance improvement for piece availability and downloaded pieces widgets --- src/downloadedpiecesbar.h | 21 ++++++++++++--------- src/pieceavailabilitybar.h | 20 +++++++++++--------- 2 files changed, 23 insertions(+), 18 deletions(-) diff --git a/src/downloadedpiecesbar.h b/src/downloadedpiecesbar.h index 5f9c5c96a..3a04d9073 100644 --- a/src/downloadedpiecesbar.h +++ b/src/downloadedpiecesbar.h @@ -63,28 +63,31 @@ public: const qulonglong nb_pieces = pieces.size(); // Reduce the number of pieces before creating the pixmap // otherwise it can crash when there are too many pieces - if(nb_pieces > (uint)width()) { - const int ratio = floor(nb_pieces/(double)width()); - std::vector scaled_pieces; - std::vector scaled_downloading; + const uint w = width(); + if(nb_pieces > w) { + const uint ratio = floor(nb_pieces/(double)w); + bitfield scaled_pieces(ceil(nb_pieces/(double)ratio), false); + bitfield scaled_downloading(ceil(nb_pieces/(double)ratio), false); + uint scaled_index = 0; for(qulonglong i=0; i width()) { - const int ratio = floor(nb_pieces/(double)width()); + const uint w = width(); + if(nb_pieces > w) { + const qulonglong ratio = floor(nb_pieces/(double)w); std::vector scaled_avail; - for(int i=0; i