3 ms·
> and a copy might happen if needed or the same portion of memory will be used if the compiler can avoid the copy How can I definitively tell which of the two
by abraxas 7y ago
> and a copy might happen if needed or the same portion of memory will be used if the compiler can avoid the copy
How can I definitively tell which of the two things will happen? Under what conditions will it choose to make a copy instead of passing the address?
- estebank 7y agoScratch that, it is actually a planned feature (I thought llvm was already doing it): https://github.com/rust-lang/rust/issues/13707 https://github.com/rust-lang/rust/issues/13707 The idea is to detect large moves and do a pass by reference, much like Swift does. On my personal roadmap I have detecting these cases and lint against it, suggesting passing the argument as & or &mut as appropriate. That way the performance implications and tradeoffs are visible in the code you write/read.
- deleted 7y ago[deleted]