From 0e6f690cdfa8099558472312aa0c0b17eb941887 Mon Sep 17 00:00:00 2001 From: Cristy Date: Sun, 1 Sep 2019 12:23:04 -0400 Subject: [PATCH] Small optimization --- MagickCore/constitute.c | 8 ++++++-- MagickCore/option.c | 6 +++++- coders/jpeg.c | 12 +++++++++--- 3 files changed, 20 insertions(+), 6 deletions(-) diff --git a/MagickCore/constitute.c b/MagickCore/constitute.c index 9456536fc..4cff21f67 100644 --- a/MagickCore/constitute.c +++ b/MagickCore/constitute.c @@ -143,6 +143,9 @@ MagickExport Image *ConstituteImage(const size_t columns,const size_t rows, register ssize_t i; + size_t + length; + /* Allocate image structure. */ @@ -154,7 +157,8 @@ MagickExport Image *ConstituteImage(const size_t columns,const size_t rows, image=AcquireImage((ImageInfo *) NULL,exception); if (image == (Image *) NULL) return((Image *) NULL); - for (i=0; i < (ssize_t) strlen(map); i++) + length=strlen(map); + for (i=0; i < (ssize_t) length; i++) { switch (map[i]) { @@ -186,7 +190,7 @@ MagickExport Image *ConstituteImage(const size_t columns,const size_t rows, } default: { - if (strlen(map) == 1) + if (length == 1) image->colorspace=GRAYColorspace; break; } diff --git a/MagickCore/option.c b/MagickCore/option.c index 36379623a..cf0d7ed58 100644 --- a/MagickCore/option.c +++ b/MagickCore/option.c @@ -2850,6 +2850,9 @@ MagickExport ssize_t ParseChannelOption(const char *channels) register ssize_t i; + size_t + length; + ssize_t channel; @@ -2857,7 +2860,8 @@ MagickExport ssize_t ParseChannelOption(const char *channels) if (channel >= 0) return(channel); channel=0; - for (i=0; i < (ssize_t) strlen(channels); i++) + length=strlen(channels); + for (i=0; i < (ssize_t) length; i++) { switch (channels[i]) { diff --git a/coders/jpeg.c b/coders/jpeg.c index 087bf09d2..ecb021ffb 100644 --- a/coders/jpeg.c +++ b/coders/jpeg.c @@ -2842,9 +2842,15 @@ static MagickBooleanType WriteJPEGImage(const ImageInfo *image_info, */ value=GetImageProperty(image,"comment",exception); if (value != (char *) NULL) - for (i=0; i < (ssize_t) strlen(value); i+=65533L) - jpeg_write_marker(&jpeg_info,JPEG_COM,(unsigned char *) value+i, - (unsigned int) MagickMin((size_t) strlen(value+i),65533L)); + { + size_t + length; + + length=strlen(value); + for (i=0; i < (ssize_t) length; i+=65533L) + jpeg_write_marker(&jpeg_info,JPEG_COM,(unsigned char *) value+i, + (unsigned int) MagickMin((size_t) strlen(value+i),65533L)); + } if (image->profiles != (void *) NULL) WriteProfile(&jpeg_info,image,exception); /* -- 2.40.0