[Spice-devel] [PATCH 1/3] use local variable to compute gradual score
Frediano Ziglio
fziglio at redhat.com
Fri Aug 21 02:57:48 PDT 2015
Due to aliasing using pointers lead to some sub-optimization.
Use local variable and then write them to output to improve performances.
Signed-off-by: Frediano Ziglio <fziglio at redhat.com>
---
server/red_bitmap_utils.h | 13 ++++++++-----
1 file changed, 8 insertions(+), 5 deletions(-)
diff --git a/server/red_bitmap_utils.h b/server/red_bitmap_utils.h
index 1c13ced..7e57a7b 100644
--- a/server/red_bitmap_utils.h
+++ b/server/red_bitmap_utils.h
@@ -121,6 +121,8 @@ static void FNAME(compute_lines_gradual_score)(PIXEL *lines, int width, int num_
PIXEL *cur_pix = lines + width / 2;
PIXEL *bottom_pix;
PIXEL *last_line = lines + (num_lines - 1) * width;
+ int num_samples;
+ double samples_sum_score;
if ((width <= 1) || (num_lines <= 1)) {
*o_num_samples = 1;
@@ -128,20 +130,21 @@ static void FNAME(compute_lines_gradual_score)(PIXEL *lines, int width, int num_
return;
}
- *o_samples_sum_score = 0;
- *o_num_samples = 0;
+ samples_sum_score = 0;
+ num_samples = 0;
while (cur_pix < last_line) {
if ((cur_pix + 1 - lines) % width == 0) { // last pixel in the row
cur_pix--; // jump is bigger than 1 so we will not enter endless loop
}
bottom_pix = cur_pix + width;
- (*o_samples_sum_score) += FNAME(pixels_square_score)(cur_pix, bottom_pix);
- (*o_num_samples)++;
+ samples_sum_score += FNAME(pixels_square_score)(cur_pix, bottom_pix);
+ num_samples++;
cur_pix += jump;
}
- (*o_num_samples) *= 3;
+ (*o_samples_sum_score) = samples_sum_score;
+ (*o_num_samples) = num_samples * 3;
}
#undef PIXEL
--
2.4.3
More information about the Spice-devel
mailing list