optimization

This commit is contained in:
Nikita Zlobin 2020-05-26 22:41:19 +05:00
parent 6413a4d6f8
commit 12bea04941

View File

@ -61,12 +61,12 @@ static struct color hex_to_color(uint32_t hexValue, int dpc)
static struct color string_to_color(const char *str)
{
char *end;
uint32_t val = strtoul(str+1, &end, 16);
if (*end != '\0' && *(end+1) != '\0') {
uint_fast32_t val = strtoul(str+1, &end, 16);
if (end[0] != '\0' && end[1] != '\0') {
LOG_W("Invalid color string: '%s'", str);
}
switch (strlen(str+1)) {
switch (end - (str+1)) {
case 3: return hex_to_color((val << 4) | 0xF, 1);
case 6: return hex_to_color((val << 8) | 0xFF, 2);
case 4: return hex_to_color(val, 1);