diff mbox series

[FFmpeg-devel,3/4] avcodec/xbmdec: convert() minor speed increase

Message ID 202101311951.04220.digital@joescat.com
State Accepted
Headers show
Series [FFmpeg-devel,1/4] avcodec/xbmenc: substitute end instead of recalculating end | expand

Checks

Context Check Description
andriy/x86_make success Make finished
andriy/x86_make_fate success Make fate finished
andriy/PPC64_make success Make finished
andriy/PPC64_make_fate success Make fate finished

Commit Message

Jose Da Silva Feb. 1, 2021, 3:51 a.m. UTC
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 | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

--
2.30.0
diff mbox series

Patch

diff --git a/libavcodec/xbmdec.c b/libavcodec/xbmdec.c
index b783d5abe5..52615dc7ab 100644
--- a/libavcodec/xbmdec.c
+++ b/libavcodec/xbmdec.c
@@ -28,12 +28,12 @@ 

 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;
 }