Re: Builtin array and AA efficiency questions

2015-10-16 Thread Kagamin via Digitalmars-d-learn
On Thursday, 15 October 2015 at 21:00:37 UTC, Random D user wrote: Right. Like a handle system or AA of ValueHandles in this case. But I'll probably just hack up some custom map and reuse it's mem. Although, I'm mostly doing this for perf (realloc) and not mem size, so it might be too much

Re: Builtin array and AA efficiency questions

2015-10-16 Thread Steven Schveighoffer via Digitalmars-d-learn
On 10/15/15 5:48 PM, Random D user wrote: Ah missed your post before replying to H.S. Teoh (I should refresh more often). Thanks for reply. You're welcome! On Thursday, 15 October 2015 at 19:50:27 UTC, Steven Schveighoffer wrote: Without more context, I would say no. assumeSafeAppend is

Re: Builtin array and AA efficiency questions

2015-10-16 Thread Steven Schveighoffer via Digitalmars-d-learn
On 10/16/15 1:05 AM, Mike Parker wrote: On Thursday, 15 October 2015 at 21:48:29 UTC, Random D user wrote: An array uses a block marked for appending, assumeSafeAppend simply sets how much data is assumed to be valid. Calling assumeSafeAppend on a block not marked for appending will do nothing

Re: Builtin array and AA efficiency questions

2015-10-15 Thread Random D user via Digitalmars-d-learn
Ah missed your post before replying to H.S. Teoh (I should refresh more often). Thanks for reply. On Thursday, 15 October 2015 at 19:50:27 UTC, Steven Schveighoffer wrote: Without more context, I would say no. assumeSafeAppend is an assumption, and therefore unsafe. If you don't know what

Re: Builtin array and AA efficiency questions

2015-10-15 Thread anonymous via Digitalmars-d-learn
On Thursday, October 15, 2015 11:48 PM, Random D user wrote: > Should array have clear() as well? > Basically wrap array.length = 0; array.assumeSafeAppend(); > At least it would then be symmetric (and more intuitive) with > built-in containers. No. "clear" is too harmless a name for it to

Re: Builtin array and AA efficiency questions

2015-10-15 Thread Steven Schveighoffer via Digitalmars-d-learn
On 10/15/15 12:47 PM, Random D user wrote: So I was doing some optimizations and I came up with couple basic questions... A) What does assumeSafeAppend actually do? A.1) Should I call it always if before setting length if I want to have assumeSafeAppend semantics? (e.g. I don't know if it's

Re: Builtin array and AA efficiency questions

2015-10-15 Thread H. S. Teoh via Digitalmars-d-learn
On Thu, Oct 15, 2015 at 09:00:36PM +, Random D user via Digitalmars-d-learn wrote: > Thanks for thorough answer. > > On Thursday, 15 October 2015 at 18:46:22 UTC, H. S. Teoh wrote: [...] > >The only thing I can think of is to implement this manually, e.g., by > >wrapping your AA in a type

Re: Builtin array and AA efficiency questions

2015-10-15 Thread Random D user via Digitalmars-d-learn
Thanks for thorough answer. On Thursday, 15 October 2015 at 18:46:22 UTC, H. S. Teoh wrote: It adjusts the size of the allocated block in the GC so that subsequent appends will not reallocate. So how does capacity affect this? I mean what is exactly a GC block here. Shrink to fit bit

Re: Builtin array and AA efficiency questions

2015-10-15 Thread Mike Parker via Digitalmars-d-learn
On Thursday, 15 October 2015 at 21:48:29 UTC, Random D user wrote: An array uses a block marked for appending, assumeSafeAppend simply sets how much data is assumed to be valid. Calling assumeSafeAppend on a block not marked for appending will do nothing except burn CPU cycles. So yours is

Builtin array and AA efficiency questions

2015-10-15 Thread Random D user via Digitalmars-d-learn
So I was doing some optimizations and I came up with couple basic questions... A) What does assumeSafeAppend actually do? A.1) Should I call it always if before setting length if I want to have assumeSafeAppend semantics? (e.g. I don't know if it's called just before the function I'm in) A.2)

Re: Builtin array and AA efficiency questions

2015-10-15 Thread H. S. Teoh via Digitalmars-d-learn
On Thu, Oct 15, 2015 at 04:47:35PM +, Random D user via Digitalmars-d-learn wrote: > So I was doing some optimizations and I came up with couple basic > questions... > > A) > What does assumeSafeAppend actually do? It adjusts the size of the allocated block in the GC so that subsequent