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.
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);
}
}