diff mbox series

[FFmpeg-devel,3/4] avcodec/xpm: Minor speed increase for mod_strcspn() use reject pointer

Message ID 202102252134.59980.digital@joescat.com
State New
Headers show
Series [FFmpeg-devel,1/4] avcodec/xpm: Minor speed increase to function hex_char_to_number()
Related show

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. 26, 2021, 5:34 a.m. UTC
Incrementing pointer *pr once is faster than computing reject[j] for each
time we need it.

Signed-off-by: Jose Da Silva <digital@joescat.com>
---
 libavcodec/xpmdec.c | 10 ++++------
 1 file changed, 4 insertions(+), 6 deletions(-)

--
2.30.1
diff mbox series

Patch

diff --git a/libavcodec/xpmdec.c b/libavcodec/xpmdec.c
index 66a9a8008c..7b3d3a7ff5 100644
--- a/libavcodec/xpmdec.c
+++ b/libavcodec/xpmdec.c
@@ -211,7 +211,8 @@  static unsigned int hex_char_to_number(uint8_t x)
  */
 static size_t mod_strcspn(const char *string, const char *reject)
 {
-    int i, j;
+    const char *pr;
+    int i;

     if (!string)
         return 0;
@@ -226,11 +227,8 @@  static size_t mod_strcspn(const char *string, const char *reject)
             while (string[i] && string[i] != '\n')
                 i++;
         } else if (reject) {
-            for (j = 0; reject[j]; j++) {
-                if (string[i] == reject[j])
-                    break;
-            }
-            if (reject[j])
+            for (pr = reject; *pr && *pr != string[i]; pr++);
+            if (*pr)
                 break;
         }
     }