[Issue 12684] New: Allow posblit elision when passing arguments to subfunctions
via Digitalmars-d-bugs
digitalmars-d-bugs at puremagic.com
Wed Apr 30 02:38:07 PDT 2014
https://issues.dlang.org/show_bug.cgi?id=12684
Issue ID: 12684
Summary: Allow posblit elision when passing arguments to
subfunctions
Product: D
Version: D2
Hardware: All
OS: All
Status: NEW
Severity: enhancement
Priority: P1
Component: DMD
Assignee: nobody at puremagic.com
Reporter: monarchdodra at gmail.com
Similar to https://issues.dlang.org/show_bug.cgi?id=12683
Long story short:
//----
void redirect(T)(T t)
{
bar(t); //Postblit here
}
void bar(T)(T t);
//----
Again, while I don't think we can elide the copy entirelly, I think we *can*
elide the postblit entirely.
Again, the reasons for allowing this are the same as 12683: There are *tons*
"redirect" functions that do nothing more than wrap a call to another
functions. The call to postblit is wasteful, and prevents usage with unique
objects.
Furthermore, this would be necessary for a more efficient "forward" template.
Currently, forward calls "T move(ref T t)". The "move" template in algorithm is
actually incredibly wasteful for types with postblits: It creates a 2
temporaries, it calls 2 memcopies, and it calls a destructor (on an object with
T.init state). *ALL* of this is exceedingly wasteful, for what should be
essentially be a no-op function...
Having this is necessary for fixing:
https://issues.dlang.org/show_bug.cgi?id=12628
emplace does not work for rvalues
--
More information about the Digitalmars-d-bugs
mailing list