Merge pull request #2301 from EvilPudding/next

Minor optimization
This commit is contained in:
Michael Stapelberg 2016-08-03 18:43:35 +02:00 committed by GitHub
commit 012de8cd6f
1 changed files with 5 additions and 2 deletions

View File

@ -13,7 +13,7 @@
#include "libi3.h"
struct Colorpixel {
char *hex;
char hex[8];
uint32_t pixel;
SLIST_ENTRY(Colorpixel)
@ -74,7 +74,10 @@ uint32_t get_colorpixel(const char *hex) {
/* Store the result in the cache */
struct Colorpixel *cache_pixel = scalloc(1, sizeof(struct Colorpixel));
cache_pixel->hex = sstrdup(hex);
strncpy(cache_pixel->hex, hex, 7);
cache_pixel->hex[7] = '\0';
cache_pixel->pixel = pixel;
SLIST_INSERT_HEAD(&(colorpixels), cache_pixel, colorpixels);