https://issues.dlang.org/show_bug.cgi?id=13159
Jakob Ovrum <[email protected]> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |[email protected] --- Comment #2 from Jakob Ovrum <[email protected]> --- I already posted a PR for this BTW: https://github.com/D-Programming-Language/phobos/pull/2351 (In reply to Orvid King from comment #1) > Assuming that infos has a length property, it would be better yet to simply > do: > > auto infos = getAddressInfo(hostname, service); > auto results = new Address[infos.length]; This would allocate even when infos.length is 0. > Which would result in exactly the amount of memory needed being allocated, > and only 1 allocation being done. `getAddressInfo` allocates too, and easily more than once, so that wouldn't be quite true. > I would also suggest the possibility of adding an OutputRange based version. We can do better - a version that returns the results as a lazy forward range. The most underlying data structure here is a singly linked list. We can use reference counting to ensure the list is freed (freeaddrinfo). It's a much heavier change though so I'm not going to do it in PR #2351. --
