cell_load_direct: shortcut for bytes <= 1

pull/893/head
nick black 4 years ago committed by Nick Black
parent 3bc15c2824
commit 81052e344c

@ -571,8 +571,8 @@ static inline void
pool_release(egcpool* pool, cell* c){
if(!cell_simple_p(c)){
egcpool_release(pool, cell_egc_idx(c));
c->gcluster = 0; // don't subject ourselves to double-release problems
}
c->gcluster = 0; // don't subject ourselves to double-release problems
}
// Duplicate one cell onto another, possibly crossing ncplanes.

@ -1364,21 +1364,31 @@ cell_load_direct(ncplane* n, cell* c, const char* gcluster, int bytes, int cols)
if(bytes < 0 || cols < 0){
return -1;
}
if(cols < 2){
c->channels &= ~CELL_WIDEASIAN_MASK;
}else{
c->channels |= CELL_WIDEASIAN_MASK;
if(bytes <= 1){
assert(cols < 2);
cell_release(n, c);
c->channels &= ~(CELL_WIDEASIAN_MASK | CELL_NOBACKGROUND_MASK);
c->gcluster = *gcluster;
return bytes;
}
// FIXME also shaded blocks! ░ etc. are there combined EGCs involving these?
if(strncmp(gcluster, "\xe2\x96\x88", 3)){
c->channels &= ~CELL_NOBACKGROUND_MASK;
if(cols < 2){
c->channels &= ~CELL_WIDEASIAN_MASK;
}else{
c->channels |= CELL_WIDEASIAN_MASK;
}
}else{
c->channels |= CELL_NOBACKGROUND_MASK;
c->channels &= ~CELL_WIDEASIAN_MASK;
}
if(bytes <= 4){
cell_release(n, c);
c->gcluster = 0;
memcpy(&c->gcluster, gcluster, bytes);
if(strcmp(gcluster, (const char*)&c->gcluster)){
cell_release(n, c);
c->gcluster = 0;
memcpy(&c->gcluster, gcluster, bytes);
}
return bytes;
}
int eoffset = egcpool_stash(&n->pool, gcluster, bytes);

Loading…
Cancel
Save