Is there a big difference in efficiency when using Point2D instead of double x and y values?
I’m working on a program that has many circles moving around the screen. They each start at one point, and get closer and closer to their destinations (finally, they stop).
Using methods like .getCurrentLocation().GetY() (where currentLocation is a Point2D), I’m experiencing slow performance with any large number of entities.
I don’t want to go back and revise all my code for no reason, so I’m asking if I would see a significant performance increase from just storing X and Y double coordinates instead of using Points.
That depends on whether you constantly create new points. If not, i.e. you reuse the existing ones, you shouldn’t get a big performance difference.
What is costly about objects in most cases is not the storage but the object creation.
However, as suggested by aix, try and use a profiler to find the real performance bottlenecks.