Hex in struct Colorpixel.hex to contiguous memory
No reason for hex not to be of a constant size, and no reason to introduce a cache miss by allocating it separated from the rest of the structure.
This commit is contained in:
parent
d77d40173a
commit
08c2380545
|
@ -13,7 +13,7 @@
|
||||||
#include "libi3.h"
|
#include "libi3.h"
|
||||||
|
|
||||||
struct Colorpixel {
|
struct Colorpixel {
|
||||||
char *hex;
|
char hex[8];
|
||||||
uint32_t pixel;
|
uint32_t pixel;
|
||||||
|
|
||||||
SLIST_ENTRY(Colorpixel)
|
SLIST_ENTRY(Colorpixel)
|
||||||
|
@ -74,7 +74,7 @@ uint32_t get_colorpixel(const char *hex) {
|
||||||
|
|
||||||
/* Store the result in the cache */
|
/* Store the result in the cache */
|
||||||
struct Colorpixel *cache_pixel = scalloc(1, sizeof(struct Colorpixel));
|
struct Colorpixel *cache_pixel = scalloc(1, sizeof(struct Colorpixel));
|
||||||
cache_pixel->hex = sstrdup(hex);
|
strncpy(cache_pixel->hex, hex, 8);
|
||||||
cache_pixel->pixel = pixel;
|
cache_pixel->pixel = pixel;
|
||||||
|
|
||||||
SLIST_INSERT_HEAD(&(colorpixels), cache_pixel, colorpixels);
|
SLIST_INSERT_HEAD(&(colorpixels), cache_pixel, colorpixels);
|
||||||
|
|
Loading…
Reference in New Issue