In addition to the rest of the answers:
You can make your class a structure. Then it will be on the stack and will be thrown for each iteration. If your structure creates new classes, you will return to the square. And if your structure is large, it can affect performance negatively, but otherwise, if it is small, it can affect performance positively.
Lasse espeholt
source share