Linked by Thom Holwerda on Fri 15th Feb 2013 10:40 UTC
Thread beginning with comment 552627
To view parent comment, click here.
To read all comments associated with this story, please click here.
To view parent comment, click here.
To read all comments associated with this story, please click here.
RE[3]: Code Review
by Bill Shooter of Bul on Fri 15th Feb 2013 15:38
in reply to "RE[2]: Code Review"
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:
2011-01-28
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