From f78b535b0d7863152b7ca463b2b499485f4ea1a7 Mon Sep 17 00:00:00 2001 From: Andre Noll Date: Sun, 3 Jun 2012 19:25:06 +0200 Subject: [PATCH] gui: Don't compute string length unnecessarily. We already know the length because it was computed earlier and stored in the ring buffer structure, so use this "cached" value instead where possible. --- gui.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/gui.c b/gui.c index a8a7fc9f..696ea1b2 100644 --- a/gui.c +++ b/gui.c @@ -403,7 +403,7 @@ static int draw_top_rbe(unsigned *lines) rbe = ringbuffer_get(bot_win_rb, fvr); if (!rbe) return -1; - len = strlen(rbe->msg); + len = rbe->len; if (*lines > bot.lines) { /* first rbe is only partially visible */ offset = (*lines - bot.lines) * bot.cols; @@ -1162,7 +1162,7 @@ static void com_scroll_top(void) struct rb_entry *rbe = ringbuffer_get(bot_win_rb, i); if (!rbe) break; - lines += NUM_LINES(strlen(rbe->msg)); + lines += NUM_LINES(rbe->len); } i++; if (lines > 0 && scroll_position != i) { @@ -1193,7 +1193,7 @@ static void com_page_down(void) struct rb_entry *rbe = ringbuffer_get(bot_win_rb, i); if (!rbe) break; - lines += NUM_LINES(strlen(rbe->msg)); + lines += NUM_LINES(rbe->len); } if (lines) { scroll_position = i; -- 2.39.5