Rewrite charmap system

Avoid allocating a *ton* of data per charmap
Stop relying on uninitialized data in charmap nodes
Only initialize charmap nodes lazily
This commit is contained in:
ISSOtm
2020-10-04 04:31:10 +02:00
parent 2e3db9d56a
commit 4cfed3c98f
10 changed files with 163 additions and 181 deletions

View File

@@ -27,21 +27,20 @@ uint32_t calchash(const char *s)
return hash;
}
int32_t readUTF8Char(char *dest, char *src)
size_t readUTF8Char(uint8_t *dest, char const *src)
{
uint32_t state;
uint32_t state = 0;
uint32_t codep;
int32_t i;
size_t i = 0;
for (i = 0, state = 0;; i++) {
for (;;) {
if (decode(&state, &codep, (uint8_t)src[i]) == 1)
fatalerror("invalid UTF-8 character\n");
dest[i] = src[i];
i++;
if (state == 0) {
dest[++i] = '\0';
if (state == 0)
return i;
}
}
}