Big Oversight with readln?
Mike Parker via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Thu Feb 23 23:38:04 PST 2017
On Friday, 24 February 2017 at 04:22:17 UTC, Jonathan Marler
wrote:
>
> I discovered the .capacity property of arrays. I don't know
> why I've never seen this but it looks like this is how readln
> is recovering this seemingly lost peice of data. This does
> have an odd consequence though, if you pass a slice into readln
> it will read past the end of it if the underlying buffer is
> larger. This might be something worth adding to the
> documentation.
>
> Also I'm not completely sure how .capacity works, I assume it
> has to look up this information in the memory management
> metadata. Any enlightenment on this subject is appreciated. It
> also says it's a O(log(n)) operation so I'm guessing it's
> looking it up in some sort of binary tree data structure.
https://dlang.org/phobos/object.html#.capacity
More information about the Digitalmars-d-learn
mailing list