From 554f06fdbe5cf24359040bc2eeb345148517aa8f Mon Sep 17 00:00:00 2001 From: Matthew Fernandez Date: Tue, 16 Nov 2021 19:09:22 -0800 Subject: [PATCH] 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. --- lib/gvc/gvusershape.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) 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: */ -- 2.40.0