diff options
author | nicm <nicm> | 2015-11-13 08:09:28 +0000 |
---|---|---|
committer | nicm <nicm> | 2015-11-13 08:09:28 +0000 |
commit | c5689a5a4031a43769b8b721cafa6d1eab6abc44 (patch) | |
tree | 8eb234cb05f7934a41365dc0674794ccb34561c5 /utf8.c | |
parent | e71a9154126c7ee853b9a657678de40d475279eb (diff) |
Long overdue change to the way we store cells in the grid: now, instead
of storing a full grid_cell with UTF-8 data and everything, store a new
type grid_cell_entry. This can either be the cell itself (for ASCII
cells), or an offset into an extended array (per line) for UTF-8
data.
This avoid a large (8 byte) overhead on non-UTF-8 cells (by far the
majority for most users) without the complexity of the shadow array we
had before. Grid memory without any UTF-8 is about half.
The disadvantage that cells can no longer be modified in place and need
to be copied out of the grid and back but it turned out to be lot less
complicated than I expected.
Diffstat (limited to 'utf8.c')
-rw-r--r-- | utf8.c | 17 |
1 files changed, 17 insertions, 0 deletions
@@ -352,10 +352,27 @@ static void utf8_build(void); void utf8_set(struct utf8_data *ud, u_char ch) { + u_int i; + *ud->data = ch; ud->size = 1; ud->width = 1; + + for (i = ud->size; i < sizeof ud->data; i++) + ud->data[i] = '\0'; +} + +/* Copy UTF-8 character. */ +void +utf8_copy(struct utf8_data *to, const struct utf8_data *from) +{ + u_int i; + + memcpy(to, from, sizeof *to); + + for (i = to->size; i < sizeof to->data; i++) + to->data[i] = '\0'; } /* |