digitalmars.D.learn - Why is `Appender._data` a pointer to its `Data`-store?
- Per =?UTF-8?B?Tm9yZGzDtnc=?= (8/8) Oct 16 2020 Why is `Appender`'s store `Data` put directly as
- Steven Schveighoffer (3/17) Oct 16 2020 Appender is ref counted IIRC.
- Paul Backus (3/5) Oct 16 2020 It's not; it uses the GC.
- Steven Schveighoffer (8/14) Oct 17 2020 Oh yeah. In fact, it was me who did that (in 2010!).
Why is `Appender`'s store `Data` put directly as `private Data* _data;` instead of `private Data _data;` ? Removing the pointer indirection would give better locality. If it's about optimizing for empty `Appender`s then a `Appender*` should be used in those cases instead.
Oct 16 2020
On 10/16/20 5:40 PM, Per Nordlöw wrote:Why is `Appender`'s store `Data` put directly as `private Data* _data;` instead of `private Data _data;` ? Removing the pointer indirection would give better locality. If it's about optimizing for empty `Appender`s then a `Appender*` should be used in those cases instead.Appender is ref counted IIRC. -Steve
Oct 16 2020
On Saturday, 17 October 2020 at 00:06:31 UTC, Steven Schveighoffer wrote:Appender is ref counted IIRC. -SteveIt's not; it uses the GC.
Oct 16 2020
On 10/17/20 12:00 AM, Paul Backus wrote:On Saturday, 17 October 2020 at 00:06:31 UTC, Steven Schveighoffer wrote:Oh yeah. In fact, it was me who did that (in 2010!). My point should have been that the appender is a pImpl to avoid memory corruption. If you have multiple copies of an appender, and each has its own idea of what the capacity is, then you will get corruption. See the original bug report here: https://issues.dlang.org/show_bug.cgi?id=4681 -SteveAppender is ref counted IIRC.It's not; it uses the GC.
Oct 17 2020