My general policy for by-value vs by-ref arguments in Rust is to take anything bigger than one register on 64-bit by reference. It might not always be 100% optimal on every architecture, but LLVM usually optimizes it, and it’s an easy and consistent rule to remember.
-
-
The llvm doc mentions a pass that does the opposite (turn some by-ref into by-value args) for some non-exported functions. All of this depends on whether the fn is a good inlining candidate and whether it is private to the crate.
-
My rule of thumb is by ref for things that is larger than 128 bits. I don't have anything to back whether or not it's a good rule but at least I don't spend time pondering every time I add a function. We do have large things passed/returned by values generating ugly memcpys in WR
- 4 more replies
New conversation -
Loading seems to be taking a while.
Twitter may be over capacity or experiencing a momentary hiccup. Try again or visit Twitter Status for more information.