From: Cristy Date: Fri, 15 Sep 2017 23:50:16 +0000 (-0400) Subject: Utilize Splay trees to improve performance when requesting coders modules X-Git-Tag: 7.0.7-3~27 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=038df5e9be932c1dc2e343909ad5706a8b95bbf9;p=imagemagick Utilize Splay trees to improve performance when requesting coders modules --- diff --git a/MagickCore/magick.c b/MagickCore/magick.c index d17cde90f..7f2b23415 100644 --- a/MagickCore/magick.c +++ b/MagickCore/magick.c @@ -598,51 +598,42 @@ MagickExport const MagickInfo *GetMagickInfo(const char *name, ExceptionInfo *exception) { register const MagickInfo - *p; + *magick_info; + /* + Find named module attributes. + */ assert(exception != (ExceptionInfo *) NULL); if (IsMagickTreeInstantiated(exception) == MagickFalse) return((const MagickInfo *) NULL); + magick_info=(const MagickInfo *) NULL; #if defined(MAGICKCORE_MODULES_SUPPORT) - if ((name != (const char *) NULL) && (LocaleCompare(name,"*") == 0)) - (void) OpenModules(exception); -#endif - /* - Find name in list. - */ - LockSemaphoreInfo(magick_semaphore); - ResetSplayTreeIterator(magick_list); - p=(const MagickInfo *) GetNextValueInSplayTree(magick_list); - if ((name == (const char *) NULL) || (LocaleCompare(name,"*") == 0)) + if ((name != (const char *) NULL) && (*name != '\0')) { - ResetSplayTreeIterator(magick_list); - p=(const MagickInfo *) GetNextValueInSplayTree(magick_list); + LockSemaphoreInfo(magick_semaphore); + if (LocaleCompare(name,"*") == 0) + (void) OpenModules(exception); + else + { + magick_info=(const MagickInfo *) GetValueFromSplayTree(magick_list, + name); + if (magick_info == (const MagickInfo *) NULL) + (void) OpenModule(name,exception); + } UnlockSemaphoreInfo(magick_semaphore); - return(p); } - while (p != (const MagickInfo *) NULL) - { - if (LocaleCompare(p->name,name) == 0) - break; - p=(const MagickInfo *) GetNextValueInSplayTree(magick_list); - } -#if defined(MAGICKCORE_MODULES_SUPPORT) - if (p == (const MagickInfo *) NULL) +#endif + if ((name == (const char *) NULL) || (LocaleCompare(name,"*") == 0)) { - if (*name != '\0') - (void) OpenModule(name,exception); + LockSemaphoreInfo(magick_semaphore); ResetSplayTreeIterator(magick_list); - p=(const MagickInfo *) GetNextValueInSplayTree(magick_list); - while (p != (const MagickInfo *) NULL) - { - if (LocaleCompare(p->name,name) == 0) - break; - p=(const MagickInfo *) GetNextValueInSplayTree(magick_list); - } + magick_info=(const MagickInfo *) GetNextValueInSplayTree(magick_list); + UnlockSemaphoreInfo(magick_semaphore); + return(magick_info); } -#endif - UnlockSemaphoreInfo(magick_semaphore); - return(p); + if (magick_info == (const MagickInfo *) NULL) + magick_info=(const MagickInfo *) GetValueFromSplayTree(magick_list,name); + return(magick_info); } /* diff --git a/MagickWand/compare.c b/MagickWand/compare.c index 5181dbc74..2be43d59f 100644 --- a/MagickWand/compare.c +++ b/MagickWand/compare.c @@ -141,6 +141,7 @@ static MagickBooleanType CompareUsage(void) "-extract geometry extract area from image", "-format \"string\" output formatted image characteristics", "-fuzz distance colors within this distance are considered equal", + "-gravity type horizontal and vertical text placement", "-highlight-color color", " empasize pixel differences with this color", "-identify identify the format and characteristics of the image", @@ -701,6 +702,27 @@ WandExport MagickBooleanType CompareImagesCommand(ImageInfo *image_info, } ThrowCompareException(OptionError,"UnrecognizedOption",option) } + case 'g': + { + if (LocaleCompare("gravity",option+1) == 0) + { + ssize_t + gravity; + + if (*option == '+') + break; + i++; + if (i == (ssize_t) argc) + ThrowCompareException(OptionError,"MissingArgument",option); + gravity=ParseCommandOption(MagickGravityOptions,MagickFalse, + argv[i]); + if (gravity < 0) + ThrowCompareException(OptionError,"UnrecognizedGravityType", + argv[i]); + break; + } + ThrowCompareException(OptionError,"UnrecognizedOption",option) + } case 'h': { if ((LocaleCompare("help",option+1) == 0) || diff --git a/utilities/compare.1.in b/utilities/compare.1.in index 2a9bfc49d..455a1c682 100644 --- a/utilities/compare.1.in +++ b/utilities/compare.1.in @@ -28,6 +28,7 @@ Image Settings: \-extract geometry extract area from image \-format "string" output formatted image characteristics \-fuzz distance colors within this distance are considered equal + \-gravity type horizontal and vertical text placement \-identify identify the format and characteristics of the image \-interlace type type of image interlacing scheme \-highlight-color color