From 507281610935fb2adcbae0c5f0d6239defdd8ffa Mon Sep 17 00:00:00 2001 From: Max Horn Date: Fri, 14 Apr 2006 01:47:33 +0000 Subject: Use const keyword to help compiler optimize code svn-id: r21866 --- graphics/primitives.cpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/graphics/primitives.cpp b/graphics/primitives.cpp index 791e9de64b..0b3d154fcf 100644 --- a/graphics/primitives.cpp +++ b/graphics/primitives.cpp @@ -26,22 +26,22 @@ namespace Graphics { void drawLine(int x0, int y0, int x1, int y1, int color, void (*plotProc)(int, int, int, void *), void *data) { // Bresenham's line algorithm, as described by Wikipedia - bool steep = ABS(y1 - y0) > ABS(x1 - x0); + const bool steep = ABS(y1 - y0) > ABS(x1 - x0); if (steep) { SWAP(x0, y0); SWAP(x1, y1); } - int delta_x = ABS(x1 - x0); - int delta_y = ABS(y1 - y0); - int err = 0; - int delta_err = delta_y; + const int delta_x = ABS(x1 - x0); + const int delta_y = ABS(y1 - y0); + const int delta_err = delta_y; int x = x0; int y = y0; + int err = 0; - int x_step = (x0 < x1) ? 1 : -1; - int y_step = (y0 < y1) ? 1 : -1; + const int x_step = (x0 < x1) ? 1 : -1; + const int y_step = (y0 < y1) ? 1 : -1; if (steep) (*plotProc)(y, x, color, data); -- cgit v1.2.3