Javaで何が速いか。配列インデックスに直接複数回アクセスするか、配列インデックスの値を新しい変数に保存して、これを次の計算に使用しますか?
アクセスインデックス
if ((shape.vertices[0].x >= fromX && shape.vertices[0].x <= toX) || // left side of shape in screen
(shape.vertices[0].x <= fromX && shape.vertices[0].x + shape.width >= fromX) || // right side of shape in screen
(shape.vertices[0].x >= fromX && shape.vertices[0].x + shape.width <= toX)) { // shape fully in screen
// ...
}
一時変数
float x = shape.vertices[0].x;
float y = shape.vertices[0].y;
if ((x >= fromX && x <= toX) || // left side of shape in screen
(x <= fromX && x + shape.width >= fromX) || // right side of shape in screen
(x >= fromX && x + shape.width <= toX)) { // shape fully in screen
// ...
}