Say I've got a very lightweight object:
public class Point {
public int x;
public int y;
public Point(int ax, int ay){
x = ax;
y = ay;
}
}
And I need to calculate distance very frequently - for example, during a scroll event on a mobile device that might fire several times per second.
If it keeps the code a little cleaner and more transparent to use new Point(a, b) each time, is the performance hit significant enough that I should consider caching a few references and update the member variables (as opposed to instantiation)?