mirror of
https://github.com/dankamongmen/notcurses.git
synced 2024-10-31 15:20:13 +00:00
fwrite vs ncputs
theoretically, fwrite() could get better performance than fputs() due to knowing the length of its input buffer. i didn't see any perf change beyond noise, but who knows.
This commit is contained in:
parent
465390f5e1
commit
de69fd858b
@ -58,6 +58,7 @@ typedef enum {
|
||||
// protocol, we just have to rewrite them.
|
||||
typedef struct sprixel {
|
||||
char* glyph; // glyph; can be quite large
|
||||
int glyphlen;
|
||||
uint32_t id; // embedded into glusters field of nccell, 24 bits
|
||||
struct ncplane* n; // associated ncplane
|
||||
sprixel_e invalidated;
|
||||
|
@ -723,7 +723,7 @@ term_esc_rgb(FILE* out, bool foreground, unsigned r, unsigned g, unsigned b){
|
||||
}
|
||||
rgbbuf[offset++] = 'm';
|
||||
rgbbuf[offset] = '\0';
|
||||
if(ncfputs(rgbbuf, out) == EOF){
|
||||
if(fwrite(rgbbuf, offset, 1, out) != 1){
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
@ -971,7 +971,7 @@ rasterize_sprixels(notcurses* nc, const ncpile* p, FILE* out){
|
||||
if(goto_location(nc, out, y + nc->stdplane->absy, x + nc->stdplane->absx)){
|
||||
return -1;
|
||||
}
|
||||
if(ncfputs(s->glyph, out) < 0){
|
||||
if(fwrite(s->glyph, s->glyphlen, 1, out) != 1){
|
||||
return -1;
|
||||
}
|
||||
s->invalidated = SPRIXEL_NOCHANGE;
|
||||
|
@ -39,6 +39,7 @@ sprixel* sprixel_create(ncplane* n, const char* s, int bytes, int placey, int pl
|
||||
free(ret);
|
||||
return NULL;
|
||||
}
|
||||
ret->glyphlen = bytes;
|
||||
ret->tacache = tacache;
|
||||
ret->invalidated = SPRIXEL_INVALIDATED;
|
||||
ret->n = n;
|
||||
|
Loading…
Reference in New Issue
Block a user