mirror of
https://github.com/d47081/qBittorrent.git
synced 2025-02-05 11:24:15 +00:00
Code optimization
This commit is contained in:
parent
af3755bf91
commit
52b3926f92
@ -64,7 +64,7 @@ public:
|
|||||||
// Reduce the number of pieces before creating the pixmap
|
// Reduce the number of pieces before creating the pixmap
|
||||||
// otherwise it can crash when there are too many pieces
|
// otherwise it can crash when there are too many pieces
|
||||||
if(nb_pieces > width()) {
|
if(nb_pieces > width()) {
|
||||||
int ratio = floor(nb_pieces/(double)width());
|
const int ratio = floor(nb_pieces/(double)width());
|
||||||
std::vector<bool> scaled_pieces;
|
std::vector<bool> scaled_pieces;
|
||||||
std::vector<bool> scaled_downloading;
|
std::vector<bool> scaled_downloading;
|
||||||
for(int i=0; i<nb_pieces; i+= ratio) {
|
for(int i=0; i<nb_pieces; i+= ratio) {
|
||||||
|
@ -51,7 +51,7 @@ public:
|
|||||||
setFixedHeight(BAR_HEIGHT);
|
setFixedHeight(BAR_HEIGHT);
|
||||||
}
|
}
|
||||||
|
|
||||||
double setAvailability(std::vector<int>& avail) {
|
double setAvailability(const std::vector<int>& avail) {
|
||||||
double average = 0;
|
double average = 0;
|
||||||
if(avail.empty()) {
|
if(avail.empty()) {
|
||||||
// Empty bar
|
// Empty bar
|
||||||
@ -60,12 +60,12 @@ public:
|
|||||||
pixmap = pix;
|
pixmap = pix;
|
||||||
} else {
|
} else {
|
||||||
// Look for maximum value
|
// 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;
|
average = std::accumulate(avail.begin(), avail.end(), 0)/(double)nb_pieces;
|
||||||
// Reduce the number of pieces before creating the pixmap
|
// Reduce the number of pieces before creating the pixmap
|
||||||
// otherwise it can crash when there are too many pieces
|
// otherwise it can crash when there are too many pieces
|
||||||
if(nb_pieces > width()) {
|
if(nb_pieces > width()) {
|
||||||
int ratio = floor(nb_pieces/(double)width());
|
const int ratio = floor(nb_pieces/(double)width());
|
||||||
std::vector<int> scaled_avail;
|
std::vector<int> scaled_avail;
|
||||||
for(int i=0; i<nb_pieces; i+= ratio) {
|
for(int i=0; i<nb_pieces; i+= ratio) {
|
||||||
int j = i;
|
int j = i;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user