From 49ceb676b01fadfd97c1a829c9228e3ca8ac733c Mon Sep 17 00:00:00 2001 From: Lars Magne Ingebrigtsen Date: Fri, 16 Aug 2013 17:31:04 +0200 Subject: [PATCH] (imagemagick_load_image): Remove the ping_wand code The apparently only saved time on invalid animated images, and slowed down everything else. Optimise for the common case. --- src/ChangeLog | 3 +++ src/image.c | 43 ++++++++++--------------------------------- 2 files changed, 13 insertions(+), 33 deletions(-) diff --git a/src/ChangeLog b/src/ChangeLog index de9724238a0..035a4169399 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -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 diff --git a/src/image.c b/src/image.c index 3607be1e86c..198d5545c96 100644 --- a/src/image.c +++ b/src/image.c @@ -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) -- 2.39.2