C#で次の式があり、chunkWidth
事前chunkHeight
に計算された数値が固定されている場合、モジュロ除算の一部を事前に計算することで式を最適化することは可能ですか?
// Once assigned these guys never change
private int _chunkWidth;
private int _chunkHeight;
// This function needs to be super optimal!
SomeObject LookupObject(int row, int column) {
int index = (row % _chunkHeight) * _chunkWidth + (column % _chunkWidth);
return _objects[ index ];
}