]> git.sesse.net Git - ffmpeg/commitdiff
avcodec/xbmdec: convert() minor speed increase
authorJose Da Silva <digital@joescat.com>
Mon, 1 Feb 2021 03:51:04 +0000 (19:51 -0800)
committerPaul B Mahol <onemda@gmail.com>
Wed, 3 Feb 2021 15:03:15 +0000 (16:03 +0100)
If we test for {0..9} first, we have tested for 10/16th of all possible
characters first and avoid testing the remaining 6/16th of all possible
characters, which can be either 6/16th lowercase or 6/16th uppercase.

Signed-off-by: Joe Da Silva <digital@joescat.com>
libavcodec/xbmdec.c

index b783d5abe5ee8d827b1489d7864a0df146f53f39..52615dc7ab2c8e972ed886633e6508dd0d9cf575 100644 (file)
 
 static int convert(uint8_t x)
 {
-    if (x >= 'a')
-        x -= 87;
-    else if (x >= 'A')
-        x -= 55;
-    else
+    if (x <= '9')
         x -= '0';
+    else if (x >= 'a')
+        x -= ('a' - 10);
+    else
+        x -= ('A' - 10);
     return x;
 }