[Issue 20711] New: object.update requires the "update" callback to wastefully return a copy of the updated value
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Tue Mar 31 05:04:00 UTC 2020
https://issues.dlang.org/show_bug.cgi?id=20711
Issue ID: 20711
Summary: object.update requires the "update" callback to
wastefully return a copy of the updated value
Product: D
Version: D2
Hardware: All
OS: All
Status: NEW
Keywords: performance
Severity: enhancement
Priority: P1
Component: druntime
Assignee: nobody at puremagic.com
Reporter: dlang-bugzilla at thecybershadow.net
Here is the current implementation:
https://github.com/dlang/druntime/blob/master/src/object.d#L2670
The line in question is:
*p = update(*p);
This seems like a wasteful copy to me, and negatively affects AAs with value
types which are large or have destructors / postblit constructors. Instead, the
update callback can just write to its ref parameter.
I propose to make object.update accept an "update" callback which returns void;
in which case, simply omit the first part of the above statement.
--
More information about the Digitalmars-d-bugs
mailing list