SDL: More efficient calculation of render_count

From 4ef2529bf96edb145bcba2b5466fa8493866d37a Mon Sep 17 00:00:00 2001
From: Sam Lantinga <[EMAIL REDACTED]>
Date: Sat, 8 Jan 2022 12:37:57 -0800
Subject: [PATCH] More efficient calculation of render_count

---
 src/render/SDL_render.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/src/render/SDL_render.c b/src/render/SDL_render.c
index bb9dfaa0b01..c23e01c40c5 100644
--- a/src/render/SDL_render.c
+++ b/src/render/SDL_render.c
@@ -2832,7 +2832,7 @@ static int plotLineLow(SDL_Renderer *renderer, float x0, float y0, float x1, flo
 
     D = (2 * dy) - dx;
     y = y0;
-    for (render_count = 0, x = x0; x <= x1; ++x, ++render_count) {
+    for (x = x0; x <= x1; ++x) {
         tmp->x = x;
         tmp->y = y;
         tmp++;
@@ -2843,6 +2843,7 @@ static int plotLineLow(SDL_Renderer *renderer, float x0, float y0, float x1, flo
             D += 2*dy;
         }
     }
+    render_count = (tmp - points);
 
     if (!draw_last) {
         --render_count;
@@ -2889,7 +2890,7 @@ static int plotLineHigh(SDL_Renderer *renderer, float x0, float y0, float x1, fl
 
     D = (2 * dx) - dy;
     x = x0;
-    for (render_count = 0, y = y0; y <= y1; ++y, ++render_count) {
+    for (y = y0; y <= y1; ++y) {
         tmp->x = x;
         tmp->y = y;
         tmp++;
@@ -2900,6 +2901,7 @@ static int plotLineHigh(SDL_Renderer *renderer, float x0, float y0, float x1, fl
             D += 2*dx;
         }
     }
+    render_count = (tmp - points);
 
     if (!draw_last) {
         --render_count;