Hi guys,
I would like to optimize this piece of code. Anyone has any ideas?
Could I read assign two grid cells at the time or something? Can I just assign one row of cells to a temporary variable and then copy it to the grid? I don't just stupid ideas, probably wouldn't help.
I would like to optimize this piece of code. Anyone has any ideas?
- Code:
struct tgrid {
tsprite *s;
tgrid *prev;
};
__forceinline void AddGridD (tgrid *&nd, tsprite *s)
{
tgrid *n = (tgrid *)malloc(sizeof(tgrid));
n->s = s;
n->prev = nd;
nd = n;
}
// main part here
for (int y = y1; y <= y2; y++)
{
tgrid **g = (grid + (y * GRIDHEIGHT) + x1);
for (int x = x1; x <= x2; x++)
{
AddGridD(*g, s);
g++;
}
}
Could I read assign two grid cells at the time or something? Can I just assign one row of cells to a temporary variable and then copy it to the grid? I don't just stupid ideas, probably wouldn't help.