On Friday, 10 July 2020 at 21:24:08 UTC, Ali Çehreli wrote:
What is important is overhead:
That's the major point I took from all this.
Thanks for your effort.
And thanks everybody else, too, I really appreciate it.
On 7/10/20 8:03 AM, wjoe wrote:
> What I'm saying is even if this allocation is slow let's say 5ms, but it
> only happens once, that wouldn't matter to overall performance at all.
Yes, you are correct and there are dynamic arrays that are allocated
once in many programs.
I haven't read the
On Friday, 10 July 2020 at 14:20:15 UTC, wjoe wrote:
On Friday, 10 July 2020 at 10:47:49 UTC, psycha0s wrote:
On Friday, 10 July 2020 at 10:13:23 UTC, wjoe wrote:
A static array resides in this memory (with a fixed length, so
a length needn't be stored because bounds can be checked at
compile
On Friday, 10 July 2020 at 11:13:51 UTC, Stanislav Blinov wrote:
On Friday, 10 July 2020 at 10:13:23 UTC, wjoe wrote:
So many awesome answers, thank you very much everyone!
Less overhead,
Using/needing it to interface with something else, and
Efficiency are very good points.
However stack
On Friday, 10 July 2020 at 10:47:49 UTC, psycha0s wrote:
On Friday, 10 July 2020 at 10:13:23 UTC, wjoe wrote:
However stack memory needs to be allocated at program start. I
don't see a huge benefit in allocation speed vs. heap
pre-allocation, or is there?
I mean 1 allocation vs 2 isn't going
On Friday, 10 July 2020 at 10:13:23 UTC, wjoe wrote:
However stack memory needs to be allocated at program start. I
don't see a huge benefit in allocation speed vs. heap
pre-allocation, or is there?
I mean 1 allocation vs 2 isn't going to noticeably improve
overall performance.
You seem to
On Friday, 10 July 2020 at 10:13:23 UTC, wjoe wrote:
So many awesome answers, thank you very much everyone!
Less overhead,
Using/needing it to interface with something else, and
Efficiency are very good points.
However stack memory needs to be allocated at program start. I
don't see a huge
On Friday, 10 July 2020 at 10:13:23 UTC, wjoe wrote:
However stack memory needs to be allocated at program start. I
don't see a huge benefit in allocation speed vs. heap
pre-allocation, or is there?
I mean 1 allocation vs 2 isn't going to noticeably improve
overall performance.
Allocation on
On Thursday, 9 July 2020 at 17:15:26 UTC, Jonathan M Davis wrote:
On Thursday, July 9, 2020 10:21:41 AM MDT H. S. Teoh via
Digitalmars-d-learn wrote:
> - Assignment copies the whole array, as in int[5] a; auto b
> = a;
Sometimes this is desirable. Consider the 3D game example.
Suppose
So many awesome answers, thank you very much everyone!
Less overhead,
Using/needing it to interface with something else, and
Efficiency are very good points.
However stack memory needs to be allocated at program start. I
don't see a huge benefit in allocation speed vs. heap
pre-allocation, or
On Thursday, 9 July 2020 at 18:51:47 UTC, Paul Backus wrote:
Note that using VLAs in C is widely considered to be bad
practice, and that they were made optional in the C11 standard.
If you want to allocate an array on the stack, the best way is
to use a static array for size below a
On Thursday, 9 July 2020 at 18:02:02 UTC, IGotD- wrote:
Static arrays are great because as already mentioned, they are
allocated on the stack (unless it is global variable something,
then it ends up in the data segment or TLS area).
As C/C++ now allows dynamically sized static arrays (for
On Thu, Jul 09, 2020 at 06:02:02PM +, IGotD- via Digitalmars-d-learn wrote:
[...]
> Is this the reason that ubyte[arraySize] doesn't create a dynamic
> array with size arraySize?
>
> Now you need to do.
>
> ubyte[] arr;
> arr.length = arraySize;
Nah, just do this:
arr = new
On Thursday, 9 July 2020 at 12:12:06 UTC, wjoe wrote:
...
Static arrays are great because as already mentioned, they are
allocated on the stack (unless it is global variable something,
then it ends up in the data segment or TLS area).
As C/C++ now allows dynamically sized static arrays
On Thursday, July 9, 2020 10:21:41 AM MDT H. S. Teoh via Digitalmars-d-learn
wrote:
> > - Assignment copies the whole array, as in int[5] a; auto b = a;
>
> Sometimes this is desirable. Consider the 3D game example. Suppose
> you're given a vector and need to perform some computation on it. If
On Thu, Jul 09, 2020 at 12:12:06PM +, wjoe via Digitalmars-d-learn wrote:
> + The size is known at compile time.
>
> vs.
>
> - Can neither grow nor shrink them
> - Can't append elements
> - Can't remove elements
Consider a 3D game in which you represent vectors as static arrays of 4
On 7/9/20 5:12 AM, wjoe wrote:
Considering the many downsides why would I ever want to choose a static
over a dynamic array ?
In addition to what others said, dynamic arrays can be more expensive
both in space and time.
Time: Dynamic array elements are accessed through an extra pointer
On Thursday, 9 July 2020 at 12:12:06 UTC, wjoe wrote:
Also GC but it's possible to make a dynamic array
implementation which avoids the GC.
It's easy to make a dynamic array without using the GC. Did you
mean "implementation which avoids memory management"?
I'm not considering supposed
On Thursday, 9 July 2020 at 12:12:06 UTC, wjoe wrote:
I'm not considering supposed performance benefits/penalties
because these need to be profiled.
Considering the many downsides why would I ever want to choose
a static over a dynamic array ?
Simply put: static arrays are not dynamic
19 matches
Mail list logo