Re: [dev] [st] [PATCH] Optimize memory footprint of line buffers

From: Roberto E. Vargas Caballero <k0ga_AT_shike2.com>
Date: Tue, 21 Apr 2015 19:03:57 +0200

Hi,

> Hello, I noticed that the Glyph struct was using more memory than was
> needed. Considering that the fg and bg colors have values that are
> always in the range of [0, 255], there is no need to use a uint32_t
> for them. A single byte each would suffice. Furthermore, assuming

This is a good point, because it is true that we are wasting a lot
of memory, but it is not so easy. Take a look of config.def.h:

  84 [255] = 0,
  85
  86 /* more colors can be added after 255 to use with DefaultXX */

We cannot use colors below 255, because they are used in the 256
color sequences, so if we want to add additional colors, then we
have to use colors upper 255, that is for example my case now:
     87 "#cccccc",
     88 "#333333",
     89 "wheat",
     90 "#000010",
     91 "magenta",
     92 "#45DB73"
     93 };
...
     96 /*
     97 * Default colors (colorname index)
     98 * foreground, background, cursor
     99 */
    100 static unsigned int defaultfg = 261;
    101 static unsigned int defaultbg = 259;
    102 static unsigned int defaultcs = 256;
...
    109 static unsigned int defaultitalic = 261;
    110 static unsigned int defaultunderline = 261;

I just realized that is not a good configuration, but
it doesn't matter. The problem here is that st was
designed in this way, and to change it is going to
generate segfault in all the users that update the
st version without changing the config file.

Maybe, a solution can be modify colorname to:

     63 static const char *colorname[256] = {

and force to the user to modify the colors between
0 and 256.

Guys, are you using colors upper 256?

Regards,
Received on Tue Apr 21 2015 - 19:03:57 CEST

This archive was generated by hypermail 2.3.0 : Tue Apr 21 2015 - 19:12:12 CEST