diff mbox series

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

Message ID 202102222032.17001.digital@joescat.com
State Superseded
Headers show
Series [FFmpeg-devel,1/4] avcodec/xpm: Minor speed increase to function hex_char_to_number() | 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. 23, 2021, 4:32 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 92a568041c..be5277e637 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 == 0)
         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;
         }
     }