From 9edcd68e7ddcdc4deca8c07b5b1c3c59cef13255 Mon Sep 17 00:00:00 2001 From: David Vazgenovich Shakaryan Date: Wed, 25 May 2022 00:57:32 -0700 Subject: pregenerate segment names to avoid constant mallocs --- curses.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) (limited to 'curses.c') diff --git a/curses.c b/curses.c index 174a6b9..5e5d934 100644 --- a/curses.c +++ b/curses.c @@ -131,12 +131,10 @@ void curses_draw(struct leg *l1, struct leg *l2) buflen += sprintf(buf + buflen, "%3d", v->points); flushbuf(buf, &buflen, points_colour(v->points)); - for (int j = 0; j < v->n_darts; ++j) { - char *n = segment_name(v->darts[j]); + for (int j = 0; j < v->n_darts; ++j) buflen += sprintf(buf + buflen, - j == 0 ? " %4s" :" %4s", n); - free(n); - } + j == 0 ? " %4s" : " %4s", + segment_name(v->darts[j])); flushbuf(buf, &buflen, COLOR_PAIR(C_DARTS)); } -- cgit v1.2.3-70-g09d2