Open glandium opened 5 years ago
There could be, yeah. I have a slight preference of not introducing macros unless necessary.
It looks like creating a Box::new
method that use Box::alloc().init()
is still copyless: https://rust.godbolt.org/z/GyAohL
There is probably something to be done in std to get the optimization without much troubles.
Edit: just did the same test with Vec, without success.
@Speedy37 we looked at your (interesting!) case and realized that the check for NULL returned by alloc() was missing in the version of code you copied.
The fixed version (that is in master
and 0.1.4) makes new_fast
not feasible any more: https://rust.godbolt.org/z/JgOjcn
It feels like there could be a
box!
macro that would doBox::alloc().init(...)
.