From: Andre Noll Date: Mon, 25 Mar 2013 19:08:12 +0000 (+0000) Subject: gui: Speed up add_spaces(). X-Git-Tag: v0.4.13~33^2~7 X-Git-Url: http://git.tue.mpg.de/?a=commitdiff_plain;h=e90c6c0a;p=paraslash.git gui: Speed up add_spaces(). The calls to waddstr() in this function showed up in profiles. So print the full string at once instead of calling waddstr() for each character. --- diff --git a/gui.c b/gui.c index a34f27de..6e44b09d 100644 --- a/gui.c +++ b/gui.c @@ -287,14 +287,20 @@ static char *configfile_exists(void) return file_exists(tmp)? tmp: NULL; } -/* - * print num spaces to curses window - */ +/* Print given number of spaces to curses window. */ static void add_spaces(WINDOW* win, unsigned int num) { - while (num > 0) { - num--; - waddstr(win, " "); + char space[] = " "; + unsigned sz = sizeof(space); + + while (num >= sz) { + waddstr(win, space); + num -= sz; + } + if (num > 0) { + assert(num < sz); + space[num] = '\0'; + waddstr(win, space); } }