summaryrefslogtreecommitdiff
path: root/dmagick/ImageView.d
diff options
context:
space:
mode:
authorMike Wey2011-09-19 23:01:35 +0200
committerMike Wey2011-09-19 23:01:35 +0200
commit6af7568675e3fce883a1d08878dfef7f4e412053 (patch)
tree78fe6bc0c1dec6d5c5958e94a61a0352f3bc930f /dmagick/ImageView.d
parent6e186769980be473eb17e8f3abc28a56432041cd (diff)
Reuse the Color in Pixels.opApply, Creating a new color every time considerably slows down the loop.
Diffstat (limited to 'dmagick/ImageView.d')
-rw-r--r--dmagick/ImageView.d5
1 files changed, 4 insertions, 1 deletions
diff --git a/dmagick/ImageView.d b/dmagick/ImageView.d
index fbce73c..709c81f 100644
--- a/dmagick/ImageView.d
+++ b/dmagick/ImageView.d
@@ -362,9 +362,12 @@ struct Pixels
*/
int opApply(int delegate(ref Color) dg)
{
+ Color color = new Color();
+
foreach ( ref PixelPacket pixel; pixels )
{
- Color color = new Color(pixel);
+ color.pixelPacket = pixel;
+
int result = dg(color);
pixel = color.pixelPacket;