| Thread overview | ||||||
|---|---|---|---|---|---|---|
|
March 01, 2021 Does reserve() preallocate for futher appends too? | ||||
|---|---|---|---|---|
| ||||
isn't clear for me if reserve() does preallocate memory so that that operator like arr ~= x can use previously allocate memory by reserve() or it's just used in slices like b = arr[x .. y]? | ||||
March 01, 2021 Re: Does reserve() preallocate for futher appends too? | ||||
|---|---|---|---|---|
| ||||
Posted in reply to Jack | On Monday, 1 March 2021 at 03:07:19 UTC, Jack wrote:
> isn't clear for me if reserve() does preallocate memory so that that operator like arr ~= x can use previously allocate memory by reserve() or it's just used in slices like b = arr[x .. y]?
Slicing never allocates memory. reserve extends the capacity for the ~= operator.
| |||
March 01, 2021 Re: Does reserve() preallocate for futher appends too? | ||||
|---|---|---|---|---|
| ||||
Posted in reply to Adam D. Ruppe | On Monday, 1 March 2021 at 03:12:42 UTC, Adam D. Ruppe wrote:
> On Monday, 1 March 2021 at 03:07:19 UTC, Jack wrote:
>> isn't clear for me if reserve() does preallocate memory so that that operator like arr ~= x can use previously allocate memory by reserve() or it's just used in slices like b = arr[x .. y]?
>
> Slicing never allocates memory. reserve extends the capacity for the ~= operator.
thanks
| |||
March 01, 2021 Re: Does reserve() preallocate for futher appends too? | ||||
|---|---|---|---|---|
| ||||
Posted in reply to Jack | On Monday, 1 March 2021 at 03:07:19 UTC, Jack wrote: > isn't clear for me if reserve() does preallocate memory so that that operator like arr ~= x can use previously allocate memory by reserve() or it's just used in slices like b = arr[x .. y]? You may potentially find this article of use: https://dlang.org/articles/d-array-article.html | |||
Copyright © 1999-2021 by the D Language Foundation
Permalink
Reply