font: optimise font_wrap

main
Dominik Madarász 2024-02-10 22:36:04 +01:00
parent c25f4ba912
commit 6743bc18fd
3 changed files with 3 additions and 6 deletions

View File

@ -363852,11 +363852,10 @@ const char *font_wrap(const char *text, float max_width) {
array(char*) words = strsplit(text, " "); array(char*) words = strsplit(text, " ");
static __thread int slot = 0; static __thread int slot = 0;
static __thread char *buf[16] = {0}; static __thread char *buf[16][FONT_MAX_STRING_LEN] = {0};
int len = strlen(text) + array_count(words); int len = strlen(text) + array_count(words);
slot = (slot+1) % 16; slot = (slot+1) % 16;
buf[slot] = REALLOC(buf[slot], len+1);
memset(buf[slot], 0, len+1); memset(buf[slot], 0, len+1);
char *out = buf[slot]; char *out = buf[slot];

View File

@ -2295,11 +2295,10 @@ const char *font_wrap(const char *text, float max_width) {
array(char*) words = strsplit(text, " "); array(char*) words = strsplit(text, " ");
static __thread int slot = 0; static __thread int slot = 0;
static __thread char *buf[16] = {0}; static __thread char *buf[16][FONT_MAX_STRING_LEN] = {0};
int len = strlen(text) + array_count(words); int len = strlen(text) + array_count(words);
slot = (slot+1) % 16; slot = (slot+1) % 16;
buf[slot] = REALLOC(buf[slot], len+1);
memset(buf[slot], 0, len+1); memset(buf[slot], 0, len+1);
char *out = buf[slot]; char *out = buf[slot];

View File

@ -10993,11 +10993,10 @@ const char *font_wrap(const char *text, float max_width) {
array(char*) words = strsplit(text, " "); array(char*) words = strsplit(text, " ");
static __thread int slot = 0; static __thread int slot = 0;
static __thread char *buf[16] = {0}; static __thread char *buf[16][FONT_MAX_STRING_LEN] = {0};
int len = strlen(text) + array_count(words); int len = strlen(text) + array_count(words);
slot = (slot+1) % 16; slot = (slot+1) % 16;
buf[slot] = REALLOC(buf[slot], len+1);
memset(buf[slot], 0, len+1); memset(buf[slot], 0, len+1);
char *out = buf[slot]; char *out = buf[slot];