mirror of
https://github.com/dankamongmen/notcurses.git
synced 2024-11-06 03:20:26 +00:00
cell_load(): recycle when possible #473
This commit is contained in:
parent
45b821645a
commit
a7d9220f21
@ -1324,10 +1324,10 @@ int ncplane_cursor_at(const ncplane* n, cell* c, char** gclust){
|
||||
}
|
||||
|
||||
int cell_load(ncplane* n, cell* c, const char* gcluster){
|
||||
cell_release(n, c);
|
||||
int bytes;
|
||||
int cols;
|
||||
if((bytes = utf8_egc_len(gcluster, &cols)) >= 0 && bytes <= 1){
|
||||
cell_release(n, c);
|
||||
c->channels &= ~CELL_WIDEASIAN_MASK;
|
||||
c->gcluster = *gcluster;
|
||||
return !!c->gcluster;
|
||||
@ -1337,6 +1337,13 @@ int cell_load(ncplane* n, cell* c, const char* gcluster){
|
||||
}else{
|
||||
c->channels &= ~CELL_WIDEASIAN_MASK;
|
||||
}
|
||||
if(!cell_simple_p(c)){
|
||||
if(strcmp(gcluster, cell_extended_gcluster(n, c)) == 0){
|
||||
return bytes; // reduce, reuse, recycle
|
||||
}else{
|
||||
cell_release(n, c);
|
||||
}
|
||||
}
|
||||
int eoffset = egcpool_stash(&n->pool, gcluster, bytes);
|
||||
if(eoffset < 0){
|
||||
return -1;
|
||||
|
Loading…
Reference in New Issue
Block a user