From: Andre Noll Date: Sun, 3 Jun 2012 17:25:06 +0000 (+0200) Subject: gui: Don't compute string length unnecessarily. X-Git-Tag: v0.4.13~41^2~5 X-Git-Url: http://git.tuebingen.mpg.de/?p=paraslash.git;a=commitdiff_plain;h=f78b535b0d7863152b7ca463b2b499485f4ea1a7;ds=sidebyside 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. --- 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;