Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » GEF » Optimization in Draw2D : PointList
Optimization in Draw2D : PointList [message #51750] Mon, 30 December 2002 23:08 Go to next message
Eclipse UserFriend
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 16:29 Go to previous message
Eclipse UserFriend
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
>
Previous Topic:How to leave the 'selection tool' selected after first usage?
Next Topic:Quesiton: Figure and Connection
Goto Forum:
  


Current Time: Wed Jul 17 11:55:33 GMT 2024

Powered by FUDForum. Page generated in 0.03567 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top