| 
| Optimization in Draw2D : PointList [message #51750] | Mon, 30 December 2002 18:08  |  | 
| Eclipse User  |  |  |  |  | Originally posted by: cmorvan.houston.westerngeco.slb.com 
 All -
 
 I'm not familiar at all with Draw2D, I was just looking the source
 code for fun (you know, hollidays season).
 I have a small optimization (who said very small).
 
 Replace PointList.transalte() used in SWTGraphic to draw the
 polygone and polyline.
 
 #### from
 
 public void translate(int x, int y){
 if (bounds != null)
 bounds.translate(x,y);
 for (int i=0; i<size*2; i+=2){
 points[i]   += x;
 points[i+1] += y;
 }
 }
 
 ####  to
 
 public void translate(int x, int y){
 if( x == 0 && y == 0 )
 return;
 
 if (bounds != null)
 bounds.translate(x,y);
 
 int i=size*2;
 int someInt[] = points;
 while( i > 0 ) {
 i--;
 someInt[i] += y;
 i--;
 someInt[i] += x;
 }
 }
 
 
 Else told me if the java or JIT compiler can already
 do that ! (reverse the loop and compare to 0).
 
 - Cyrille
 |  |  |  | 
| 
| Re: Optimization in Draw2D : PointList [message #51880 is a reply to message #51750] | Thu, 02 January 2003 11:29  |  | 
| Eclipse User  |  |  |  |  | Originally posted by: hudsonr.us.eye-bee-em.com 
 "Cyrille Morvan" <cmorvan@houston.westerngeco.slb.com> wrote in message
 news:auqjlk$9gl$1@rogue.oti.com...
 > All -
 >
 > I'm not familiar at all with Draw2D, I was just looking the source
 > code for fun (you know, hollidays season).
 > I have a small optimization (who said very small).
 >
 > Replace PointList.transalte() used in SWTGraphic to draw the
 > polygone and polyline.
 >
 > #### from
 >
 > public void translate(int x, int y){
 > if (bounds != null)
 > bounds.translate(x,y);
 > for (int i=0; i<size*2; i+=2){
 > points[i]   += x;
 > points[i+1] += y;
 > }
 > }
 >
 > ####  to
 >
 > public void translate(int x, int y){
 >         if( x == 0 && y == 0 )
 >                 return;
 
 I released this part.  Thanks.
 
 >
 > if (bounds != null)
 > bounds.translate(x,y);
 >
 >         int i=size*2;
 >         int someInt[] = points;
 >         while( i > 0 ) {
 >                 i--;
 > someInt[i] += y;
 >                 i--;
 > someInt[i] += x;
 > }
 > }
 >
 >
 > Else told me if the java or JIT compiler can already
 > do that ! (reverse the loop and compare to 0).
 >
 > - Cyrille
 >
 |  |  |  | 
Powered by 
FUDForum. Page generated in 0.04297 seconds