byhisdeeds a écrit :
> I have the following code that was ported from C that copies ints from
> one array to another. Can someone tell me whether they think
> that I can gain any performance using another method. I use
> ByteBuffers
> because the data is originaly read as bytes (RGBA) and the COPY
> function
> rearranges the order during the copying process.
>
I don't know if there is anothert method but you can improve the
following code,
remove the two asInBuffer() because they allocate a new Java object
and use getInt()/putInt() instead of get()/put().
>
> private void COPY(ByteBuffer d, ByteBuffer s, int TILE_SIZE, int I0,
> int J0,
> int U0, int V0, int I1, int J1, int U1, int V1, int I2, int J2, int
> U2, int V2)
> {
> int i,j,u,v,i0,j0,u0,v0,di0,dj0,du0,dv0,di,dj,du,dv,k0,k;
>
> IntBuffer rps = s.asIntBuffer();
> IntBuffer rpd = d.asIntBuffer();
> i0=I0; j0=J0; u0=U0; v0=V0;
> int TS1 = TILE_SIZE-1;
> di0=(I2-I0)/TS1; dj0=(J2-J0)/TS1;
> du0=(U2-U0)/TS1; dv0=(V2-V0)/TS1;
> di=(I1-I0)/TS1; dj=(J1-J0)/TS1;
> du=(U1-U0)/TS1; dv=(V1-V0)/TS1;
> for (k0=(TILE_SIZE-1);k0>=0;k0--)
> {
> i=i0; j=j0; u=u0; v=v0;
> for (k=k0;k>=0;k--)
> {
> rpd.put((v>>1)*TILE_SIZE+(u>>1), rps.get(j*TILE_SIZE+i));
> i+=di; j+=dj; u+=du; v+=dv;
> }
> i0+=di0; j0+=dj0; u0+=du0; v0+=dv0;
> }
> }
>
Cheers,
Rémi
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "JVM
Languages" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/jvm-languages?hl=en
-~----------~----~----~----~------~----~------~--~---