From: Matthew Fernandez Date: Wed, 17 Nov 2021 03:09:22 +0000 (-0800) Subject: jpeg_size: remove abuse of 'strchr' to search a byte array X-Git-Tag: 2.50.0~24^2~9 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=554f06fdbe5cf24359040bc2eeb345148517aa8f;p=graphviz jpeg_size: remove abuse of 'strchr' to search a byte array 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. --- diff --git a/lib/gvc/gvusershape.c b/lib/gvc/gvusershape.c index 693cfdcd6..5cff1caff 100644 --- a/lib/gvc/gvusershape.c +++ b/lib/gvc/gvusershape.c @@ -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: */