]> granicus.if.org Git - graphviz/commitdiff
jpeg_size: remove abuse of 'strchr' to search a byte array
authorMatthew Fernandez <matthew.fernandez@gmail.com>
Wed, 17 Nov 2021 03:09:22 +0000 (19:09 -0800)
committerMatthew Fernandez <matthew.fernandez@gmail.com>
Sun, 21 Nov 2021 01:09:14 +0000 (17:09 -0800)
Using `memchr` instead avoids the need to cast the array, shrinks the array
itself by avoiding the need for a NUL terminator, and makes it more obvious to
the compiler it can inline and unroll the whole thing.

lib/gvc/gvusershape.c

index 693cfdcd6e4e53c10fea90604532bfa30c766da3..5cff1caff3ad7c1a19a7ebbe62c224c026961d84 100644 (file)
@@ -346,7 +346,6 @@ static void jpeg_size (usershape_t *us) {
             0xd7,
         0xd8,                       /* Start of image */
         0xd9,                       /* End of image */
-        0
     };
 
     us->dpi = 0;
@@ -368,7 +367,7 @@ static void jpeg_size (usershape_t *us) {
          */
 
         /* A stand-alone... */
-        if (strchr ((char*)standalone_markers, marker))
+        if (memchr(standalone_markers, (int)marker, sizeof(standalone_markers)))
             continue;
 
         /* Incase of a 0xc0 marker: */