From 6af4ea67947b969b871905f0ae1504e4791d4fb0 Mon Sep 17 00:00:00 2001 From: Evan New-Schmidt Date: Wed, 22 May 2019 17:02:55 -0400 Subject: [PATCH] Simplify canvas bounds checking --- src/frontend.c | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/src/frontend.c b/src/frontend.c index 7276e61..4c6551d 100644 --- a/src/frontend.c +++ b/src/frontend.c @@ -321,13 +321,8 @@ void front_setcharcursor(char ch) { void redraw_canvas_win() { // find max ranges to draw canvas - int max_x = view_max_x; - int max_y = view_max_y; - - if (max_x >= view->canvas->num_cols - view->x) - (max_x = view->canvas->num_cols - view->x); - if (max_y >= view->canvas->num_rows - view->y) - (max_y = view->canvas->num_rows - view->y); + int max_x = min(view_max_x, view->canvas->num_cols - view->x); + int max_y = min(view_max_y, view->canvas->num_rows - view->y); // draw canvas onto window for (int x = 0; x < max_x; x++) {