Passing structs to functions
ketmar via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Sat Jul 2 14:17:44 PDT 2016
On Saturday, 2 July 2016 at 20:40:00 UTC, Adam D. Ruppe wrote:
> Using ref is wasteful there regardless.... just take an
> ordinary Point (even const is optional if it is all value but
> it doesn't hurt).
>
> I think a lot of C++ programmers overuse references. If you're
> passing a large thing, it makes sense, but for small things it
> often has an overall negative effect on performance, but I see
> people saying they ALWAYS use struct& just out of habit.
yep. passing small structs is not really different from passing
something like `(int x, int y)`. it is fast, and you spare
yourself from one indirection, which is inevitable with `ref`.
More information about the Digitalmars-d-learn
mailing list