(imagemagick_load_image): Remove the ping_wand code
authorLars Magne Ingebrigtsen <larsi@gnus.org>
Fri, 16 Aug 2013 15:31:04 +0000 (17:31 +0200)
committerLars Magne Ingebrigtsen <larsi@gnus.org>
Fri, 16 Aug 2013 15:31:04 +0000 (17:31 +0200)
The apparently only saved time on invalid animated images, and slowed
down everything else.  Optimise for the common case.

src/ChangeLog
src/image.c

index de97242..035a416 100644 (file)
@@ -2,6 +2,9 @@
 
        * image.c: Implement an ImageMagick per-image cache.
        (imagemagick_get_animation_cache): Fix a double-free error.
+       (imagemagick_load_image): Remove the ping_wand code, which only
+       apparently saved time on invalid animated images, and slowed down
+       everything else.  Optimise for the common case.
 
 2013-08-16  Xue Fuqiao  <xfq.free@gmail.com>
 
index 3607be1..198d554 100644 (file)
@@ -8095,7 +8095,6 @@ imagemagick_load_image (struct frame *f, struct image *img,
   XImagePtr ximg;
   int x, y;
   MagickWand *image_wand;
-  MagickWand *ping_wand;
   PixelIterator *iterator;
   PixelWand **pixels, *bg_wand = NULL;
   MagickPixelPacket  pixel;
@@ -8118,60 +8117,38 @@ imagemagick_load_image (struct frame *f, struct image *img,
   MagickWandGenesis ();
   image = image_spec_value (img->spec, QCindex, NULL);
   ino = INTEGERP (image) ? XFASTINT (image) : 0;
-  ping_wand = NewMagickWand ();
-  /* MagickSetResolution (ping_wand, 2, 2);   (Bug#10112)  */
+  image_wand = NewMagickWand ();
 
   if (filename)
-    status = MagickPingImage (ping_wand, filename);
+    status = MagickReadImage (image_wand, filename);
   else
     {
       filename_hint = imagemagick_filename_hint (img->spec, hint_buffer);
-      MagickSetFilename (ping_wand, filename_hint);
-      status = MagickPingImageBlob (ping_wand, contents, size);
+      MagickSetFilename (image_wand, filename_hint);
+      status = MagickReadImageBlob (image_wand, contents, size);
     }
 
   if (status == MagickFalse)
     {
-      imagemagick_error (ping_wand);
-      DestroyMagickWand (ping_wand);
+      imagemagick_error (image_wand);
+      DestroyMagickWand (image_wand);
       return 0;
     }
 
-  if (ino < 0 || ino >= MagickGetNumberImages (ping_wand))
+  if (ino < 0 || ino >= MagickGetNumberImages (image_wand))
     {
       image_error ("Invalid image number `%s' in image `%s'",
                   image, img->spec);
-      DestroyMagickWand (ping_wand);
+      DestroyMagickWand (image_wand);
       return 0;
     }
 
-  if (MagickGetNumberImages (ping_wand) > 1)
+  if (MagickGetNumberImages (image_wand) > 1)
     img->lisp_data =
       Fcons (Qcount,
-             Fcons (make_number (MagickGetNumberImages (ping_wand)),
+             Fcons (make_number (MagickGetNumberImages (image_wand)),
                     img->lisp_data));
 
-  DestroyMagickWand (ping_wand);
-
-  /* Now we know how many images are inside the file.  If it's not a
-     bundle, the number is one.  Load the image data.  */
-
-  image_wand = NewMagickWand ();
-
-  if (filename)
-    status = MagickReadImage (image_wand, filename);
-  else
-    {
-      MagickSetFilename (image_wand, filename_hint);
-      status = MagickReadImageBlob (image_wand, contents, size);
-    }
-
-  if (status == MagickFalse)
-    {
-      imagemagick_error (image_wand);
-      goto imagemagick_error;
-    }
-
   /* If we have an animated image, get the new wand based on the
      "super-wand". */
   if (MagickGetNumberImages (image_wand) > 1)