From d81fe3c22410be6beba3577c6985a07483da4694 Mon Sep 17 00:00:00 2001 From: Bad Diode Date: Thu, 20 May 2021 22:32:04 +0200 Subject: Apply asie's patch 2 for performance optimizations This patch replaces the txt_printf with the public domain posprintf library. --- src/text.h | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) (limited to 'src/text.h') diff --git a/src/text.h b/src/text.h index eb6149d..1142a73 100644 --- a/src/text.h +++ b/src/text.h @@ -250,17 +250,13 @@ txt_init_hybrid(TextMode mode, Font font, u32 *buf) { } // Print text to the screen with formatting. -void -txt_printf(char *msg, ...) { - va_list arg_list; - va_start(arg_list, msg); - char buf[512] = {0}; - // TODO: This call pulls in malloc() and a bunch of other things. - // To reduce memory usage and filesize, it would be advisable - // to replace it with something simpler. - vsiprintf(buf, msg, arg_list); - txt_puts(buf); -} + +#define txt_printf(msg, ...) \ + { \ + char buf[256] = {0}; \ + posprintf(buf, msg, ##__VA_ARGS__); \ + txt_puts(buf); \ + } void txt_clear_line_tiled(void) { -- cgit v1.2.1