classpath-patches
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [cp-patches] RFC: Fixed array index in GdkGraphics2D.updateBufferedI


From: Robert Schuster
Subject: Re: [cp-patches] RFC: Fixed array index in GdkGraphics2D.updateBufferedImage
Date: Tue, 14 Jun 2005 00:53:32 +0200
User-agent: Mozilla/5.0 (X11; U; Linux i686; de-AT; rv:1.7.8) Gecko/20050514

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hi.

Ziga Mahkovec wrote:
> This patch fixes what looks like a typo in
> gnu.java.awt.peer.gtk.GdkGraphics2D.updateBufferedImage.
> 
> It was throwing an ArrayIndexOutOfBoundsException in Apache Batik.
> 
> OK to commit?
> 
> 
> ------------------------------------------------------------------------
> 
> Index: gnu/java/awt/peer/gtk/GdkGraphics2D.java
> ===================================================================
> RCS file: 
> /cvsroot/classpath/classpath/gnu/java/awt/peer/gtk/GdkGraphics2D.java,v
> retrieving revision 1.35
> diff -u -r1.35 GdkGraphics2D.java
> --- gnu/java/awt/peer/gtk/GdkGraphics2D.java  2 Jun 2005 13:57:59 -0000       
> 1.35
> +++ gnu/java/awt/peer/gtk/GdkGraphics2D.java  12 Jun 2005 20:10:40 -0000
> @@ -500,7 +500,7 @@
>          int width = bimage.getWidth();
>          for (int y = 0; y < height; ++y)
>            for (int x = 0; x < width; ++x)
> -            bimage.setRGB(x, y, pixelBuffer[y*width+height]);
> +            bimage.setRGB(x, y, pixelBuffer[y*width + x]);
>        }
>    }
>  
The fix makes sense to me however I would prefer to see this like:
          int width = bimage.getWidth();
          int index = 0;
          for (int y = 0; y < height; ++y)
            for (int x = 0; x < width; ++x)
             bimage.setRGB(x, y, pixelBuffer[index++]);

Doing a multiplication and addition on every iteration seems quite
wasteful to me :)

cu
Robert
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.1 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFCrg5sG9cfwmwwEtoRAlnLAJ49BSSHw+gP+liACreak29nhKTxdQCfbP+u
AXcQOLmhNW/YQGiim0CyWZU=
=j3UW
-----END PGP SIGNATURE-----




reply via email to

[Prev in Thread] Current Thread [Next in Thread]