From cbadeb5e9a17fde5878b4bb4da26b406fc9e33a6 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Tue, 30 Dec 2025 21:55:23 +0530 Subject: [PATCH] Micro-optimization --- kitty/colors.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/kitty/colors.c b/kitty/colors.c index d6384be21..fa542384f 100644 --- a/kitty/colors.c +++ b/kitty/colors.c @@ -781,9 +781,13 @@ contrast(Color* self, PyObject *o) { static int hexchar_to_int(char c) { - if ('0' <= c && c <= '9') return c - '0'; - if ('a' <= c && c <= 'f') return c - 'a' + 10; - if ('A' <= c && c <= 'F') return c - 'A' + 10; + switch (c) { + START_ALLOW_CASE_RANGE + case '0' ... '9': return c - '0'; + case 'a' ... 'f': return c - 'a' + 10; + case 'A' ... 'F': return c - 'A' + 10; + END_ALLOW_CASE_RANGE + } return -1; }