]> granicus.if.org Git - imagemagick/commitdiff
Utilize Splay trees to improve performance when requesting coders modules
authorCristy <urban-warrior@imagemagick.org>
Fri, 15 Sep 2017 23:50:16 +0000 (19:50 -0400)
committerCristy <urban-warrior@imagemagick.org>
Fri, 15 Sep 2017 23:50:30 +0000 (19:50 -0400)
MagickCore/magick.c
MagickWand/compare.c
utilities/compare.1.in

index d17cde90f3100272f3f372061253086061ed5ba7..7f2b23415f6b49413871959f07f11a151e2b9b34 100644 (file)
@@ -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);
 }
 \f
 /*
index 5181dbc74ffeefcf57d1d9f3a089b50866a080ed..2be43d59f71873463e5334cf987eafe53dd02454 100644 (file)
@@ -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) ||
index 2a9bfc49d27778d04336b0123ba528d086524cc1..455a1c682bbf78d283a420bcaf88896960b02d1c 100644 (file)
@@ -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