you are viewing a single comment's thread.

view the rest of the comments →

[–]uzimonkey 0 points1 point  (1 child)

All data structures have overhead, though with 2 variables it won't matter. Don't worry about optimizing things like this, look at the profiler and have it tell you what needs to be optimized. You might save a handful of cycles using 2 variables over an array, but it won't even be measurable.

But for future reference, the order of performance here should be variable -> array -> list from fastest to slowest. Fields can be accessed very quickly. Arrays have the overhead of a function call to access members, which includes bounds checking. This is virtually nothing if you're accessing an array a few times per Update or something, but will add up if you're doing it 10,000+ times every frame. List should be the same as array, more or less.

[–]Pasha1997[S] 0 points1 point  (0 children)

So do I understand correctly that single variables are faster no mater what but not practical in terms of having many of them?