To view parent comment, click here.
To read all comments associated with this story, please click here.
Bill Shooter of Bul,
"Eh,I've always preferred using arrays rather than numerically named vars. It usually is easier that way."
I don't prefer arrays, but I guess I can see why you would.
My concern would that in many languages the arrays will have an additional performance cost though, requiring more indirection and more calls to alloc/free, and maybe more bounds checking as well. Even with C, the array might conceivably force the compiler to use a specific memory structure when the variable solution might have allowed more register optimizations. Its very hard to predict compiler's optimization behavior these days though.
Edit: How would you formulate a draw line function using arrays?
drawline(single x1, single y1, single x2, single y2);
drawline(single x[2], single y[2]);
// Above is too weird for me, structures would be a bit better.
drawline(coord p1, coord p2)
drawline(coord p[2]);
Edited 2013-02-15 15:11 UTC
Yeah, I'd use structs too. High performance graphics code isn't my specialty so maybe in some scenarios its a bad idea, but I still have a hard time believing that the performance hit outweighs the utility of an organized data structure of some sort. I mean, if its really performance critical, use assembly.





Member since:
2006-07-14
Eh,I've always preferred using arrays rather than numerically named vars. It usually is easier that way.