On 9 November 2013 00:15, Patrick Walton <pcwal...@mozilla.com> wrote: > I don't see how you can without defeating separate compilation. If I am a > function: > > fn f(s: ~str) {} > > It is `f`'s responsibility to free `s` at the end. That can't be done if > this optimization has been performed.
This is about only optimizing fn f(t: &T) cases. Suppose one has a custom 3-word struct with a destructor. Then with the current setup one cannot hope that &T as a parameter would be just as efficient as 3-word ~str as the compiler uses an extra indirection. So the idea is to say to the programmer: do not worry about this and always use &T as a parameter type - the compiler will optimize it using the best mode using internally pass-by-value if necessary. With such optimization in place there would be no difference between ~str and struct MyStruct {s: ~str} as both ~str and &MyStruct as a parameter generates exactly the same code. _______________________________________________ Rust-dev mailing list Rust-dev@mozilla.org https://mail.mozilla.org/listinfo/rust-dev