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.
@CyberShadow created dlang/druntime pull request #3012 "Fix Issue 20711 - object.update requires the "update" callback to was…" fixing this issue: - Fix Issue 20711 - object.update requires the "update" callback to wastefully return a copy of the updated value https://github.com/dlang/druntime/pull/3012
dlang/druntime pull request #3012 "Fix Issue 20711 - object.update requires the "update" callback to was…" was merged into master: - 21c47b36383720ab48625f1a46535eb7da31d7f1 by Vladimir Panteleev: Fix Issue 20711 - object.update requires the "update" callback to wastefully return a copy of the updated value https://github.com/dlang/druntime/pull/3012