Re: Asking about performance of std concatenation vs. Appender vs. custom class

2021-04-09 Thread ludo via Digitalmars-d-learn
reserving cuts down on the reallocations, but that only takes some of the time. Appending a 1000-element int array is going to go from a 16-byte block, to a 32-byte block, etc. up to a 4096 byte block. This involves roughly 8 reallocations per test. But every append requires an opaque function

Asking about performance of std concatenation vs. Appender vs. custom class

2021-04-01 Thread ludo via Digitalmars-d-learn
Hi fellow Dlangers, I am working on an old codebase, and found a re-implementation of standard dynamic arrays as a struct called [ArrayBuilder, visible on my github](https://tinyurl.com/2nr25ytt) The comment says: ```d /** * Behaves the same as built-in arrays, except about 6x faster with c

Re: why use string for this example of appender?

2021-04-01 Thread ludo via Digitalmars-d-learn
Thank Steve, I open a new thread with some corrections, better title, etc. On Wednesday, 31 March 2021 at 22:05:12 UTC, Steven Schveighoffer wrote: On 3/31/21 5:32 PM, ludo wrote: [...] ArrayBuilder should be similar in performance to Appender. I think part of the issue with appender could

Re: why use string for this example of appender?

2021-03-31 Thread ludo via Digitalmars-d-learn
Hi guys, I am working on an old software in D1, which defines at some point an array.d module. See my github file: https://tinyurl.com/5ffbmfvz If you go line 347, you see an ArrayBuilder struct, which is supposed to behave exactly like an array but with faster concatenation. The class comm

Re: is core Mutex lock "fast"?

2021-01-26 Thread ludo via Digitalmars-d-learn
However, I think this is all moot, druntime is the same as Tango. Moot you mean debatable? Or irrelevant :) Thanks to your explanations, I understand now that the dev tried to imitate a Tango feature with very old D1 code. This is 2005/2009 code And as pointed out by IGotD-, better not to me

is core Mutex lock "fast"?

2021-01-26 Thread ludo via Digitalmars-d-learn
Hi guys, still working on old D1 code, to be updated to D2. At some point the previous dev wrote a FastLock class. The top comment is from the dev himself, not me. My question is after the code. --- class FastLock { protected Mutex mutex; protected int lockCount; prot

Re: Static constructor

2021-01-18 Thread ludo via Digitalmars-d-learn
The mutex isn't more "global", it's more "local" (although, this will make it shared). Yes shared, this is what I meant by global :) Thanks, it's clearer now.

Re: Static constructor

2021-01-17 Thread ludo via Digitalmars-d-learn
Thanks, as explained I am indeed porting old code. No on the AA (as noted above). The mutex *is* created on demand. Every Object can have a mutex, and it's only created when you synchronize it for the first time. Yes alright. I think the dev made a design mistake because he called synchroniz

Re: Static constructor

2021-01-15 Thread ludo via Digitalmars-d-learn
I believe so. I've never used OpenAL so it may have additional restrictions with multithreading, but from a simple "This function is only ever executed on one thread at a time", your above suggestions should work. Apologies for the late reply. No worry and thank you. I found the low-lock pat

Re: Static constructor

2021-01-12 Thread ludo via Digitalmars-d-learn
NOTE : the entire code we are talking about is in the tiny url in my previous post. On Thursday, 7 January 2021 at 01:55:07 UTC, SealabJaster wrote: On Wednesday, 6 January 2021 at 17:05:02 UTC, ludo wrote: ... Using a static class like this seems to mostly be a design decision. So in ot

Static constructor

2021-01-06 Thread ludo via Digitalmars-d-learn
I read in the documentation "Static constructors are used to initialize static class members with values that cannot be computed at compile time" I try to understand the design of the following code: --- class OpenAL { static string[int] ALErrorLookup; static Object mutex;