News for hackers. Stuff that matters.
Re:Typedefs & Linus by gryan on Thursday October 14, 2010 @02:28PM (#1791992)
I don't know what the OP's beef is. There's nothing semantically wrong or confusing about this.

However, for simple types like int and float, there's no performance advantage to passing the value as a reference. It generally takes as long to construct the temporary reference as it does to copy the value.

For more complex types like structures or objects, then yeah, you're better off passing by reference.

Re:Typedefs & Linus by leif on Thursday October 14, 2010 @02:46PM (#1792080)
Yeah, I didn't mean "int" to be the offensive part.

Read my response. I'm not talking about performance, you shouldn't be copying around large structs or strings no matter what, I'm talking about code readability.

In general, your compiler will optimize the crap out of primitive type copies (and most struct copies too, these days) anyway, so it's less of a performance argument as it used to be.