]> git.tue.mpg.de Git - paraslash.git/commitdiff
gui: Don't compute string length unnecessarily.
authorAndre Noll <maan@systemlinux.org>
Sun, 3 Jun 2012 17:25:06 +0000 (19:25 +0200)
committerAndre Noll <maan@systemlinux.org>
Sun, 23 Dec 2012 14:03:10 +0000 (15:03 +0100)
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

diff --git a/gui.c b/gui.c
index a8a7fc9fb22c44aee4ec310467abba0fcade2e78..696ea1b233a5063488abb5bf0fafc6fae85ae9b4 100644 (file)
--- 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;