diff --git a/src/lib/internal.h b/src/lib/internal.h index 0d1cb463b..cc5dd67ab 100644 --- a/src/lib/internal.h +++ b/src/lib/internal.h @@ -530,8 +530,11 @@ term_fg_palindex(const notcurses* nc, FILE* out, unsigned pal){ } static inline const char* -extended_gcluster(const ncplane* n, const cell* c){ - return egcpool_extended_gcluster(&n->pool, c); +pool_extended_gcluster(const egcpool* pool, const cell* c){ + if(cell_simple_p(c)){ + return (const char*)&c->gcluster; + } + return egcpool_extended_gcluster(pool, c); } cell* ncplane_cell_ref_yx(ncplane* n, int y, int x); @@ -596,7 +599,7 @@ cell_duplicate_far(egcpool* tpool, cell* targ, const ncplane* splane, const cell return 0; } assert(splane); - const char* egc = extended_gcluster(splane, c); + const char* egc = cell_extended_gcluster(splane, c); size_t ulen = strlen(egc); int eoffset = egcpool_stash(tpool, egc, ulen); if(eoffset < 0){ diff --git a/src/lib/notcurses.c b/src/lib/notcurses.c index f8b06b462..fd7d11540 100644 --- a/src/lib/notcurses.c +++ b/src/lib/notcurses.c @@ -1520,12 +1520,10 @@ int ncplane_cursor_at(const ncplane* n, cell* c, char** gclust){ } const cell* src = &n->fb[nfbcellidx(n, n->y, n->x)]; memcpy(c, src, sizeof(*src)); - *gclust = NULL; - if(!cell_simple_p(src)){ - *gclust = strdup(extended_gcluster(n, src)); - if(*gclust == NULL){ - return -1; - } + if(cell_simple_p(c)){ + *gclust = NULL; + }else if((*gclust = strdup(cell_extended_gcluster(n, src))) == NULL){ + return -1; } return 0; } diff --git a/src/lib/render.c b/src/lib/render.c index 07df04a00..2e0ff7320 100644 --- a/src/lib/render.c +++ b/src/lib/render.c @@ -139,20 +139,10 @@ cellcmp_and_dupfar(egcpool* dampool, cell* damcell, const ncplane* srcplane, const cell* srccell){ if(damcell->stylemask == srccell->stylemask){ if(damcell->channels == srccell->channels){ - bool srcsimple = cell_simple_p(srccell); - bool damsimple = cell_simple_p(damcell); - if(damsimple == srcsimple){ - if(damsimple){ - if(damcell->gcluster == srccell->gcluster){ - return 0; // simple match - } - }else{ - const char* damegc = egcpool_extended_gcluster(dampool, damcell); - const char* srcegc = extended_gcluster(srcplane, srccell); - if(strcmp(damegc, srcegc) == 0){ - return 0; // EGC match - } - } + const char* srcegc = cell_extended_gcluster(srcplane, srccell); + const char* damegc = pool_extended_gcluster(dampool, damcell); + if(strcmp(damegc, srcegc) == 0){ + return 0; // EGC match } } }