Optimizing Code

1
2
3
4
5
6
7
void naive_rotate(int dim, pixel *src, pixel *dst)
{
    int i, j;

    for (j = 0; j < dim; ++j)
        for (i = 0; i < dim; ++i)
            dst[RIDX(dim-1-j, i, dim)] = src[RIDX(i, j, dim)];


Here is my code. I am trying to optimize this but I do not really know where to start. Can someone please help me?
Exactly what does RIDX do?
I don't know a lot about optimization but as far as I know you cannot really optimize a piece of code without seeing the whole program (and ideally find out where is your bottle neck).

You need to optimize this 7 lines for what? Do you think that they consume too much resources?

Have you considered finding out if you can implement some parts differently? This cannot be done without looking at your entire code.
I'd check if compiler does proper loop unrolling in this code. Compile it to assembly and see what it outputs.
Topic archived. No new replies allowed.