Page 1 of 1

Append() for Dynamic Arrays

PostPosted: Fri Aug 09, 2019 10:48 am
by Major Cooke
Append(Array <other>)

A function that copies all the data of another array and puts it on the tail end of the calling array.

When it comes to larger arrays, this will be useful if done on the engine side instead of the scripting side where Push would be needed for every element of the array we wish to append.

Right now, the most efficient manner I'm using is to use a temporary array that Copy()s the largest array, then manually pushes each member of other arrays whose data I want, but this is still a huge concern for performance. The use case here is basically to traverse multiple arrays at once without needing to repeat code, which can become problematic if there's quite a few arrays involved as it makes code organization a bit messy.

Re: Append() for Dynamic Arrays

PostPosted: Fri Aug 09, 2019 2:19 pm
by Apeirogon
A function that copies all the data of another array and puts it on the tail end of the calling array

Just curious, why you need to do this?

Re: Append() for Dynamic Arrays

PostPosted: Fri Aug 09, 2019 3:21 pm
by Major Cooke
Apeirogon wrote:Just curious, why you need to do this?


Major Cooke wrote:This is still a huge concern for performance. The use case here is basically to traverse multiple arrays at once without needing to repeat code, which can become problematic if there's quite a few arrays involved as it makes code organization a bit messy.

Re: Append() for Dynamic Arrays

PostPosted: Fri Aug 09, 2019 7:00 pm
by Matt
Also makes the code a lot easier to read if we're not having to set up for loops each time.

Re: Append() for Dynamic Arrays

PostPosted: Sat Aug 10, 2019 7:30 am
by Major Cooke
The biggest boon on top of that is the performance optimization.

Re: Append() for Dynamic Arrays

PostPosted: Sat Aug 10, 2019 8:39 am
by _mental_

Re: Append() for Dynamic Arrays

PostPosted: Sat Aug 10, 2019 9:23 am
by Major Cooke
Oooh, thank you! :mrgreen:

Re: Append() for Dynamic Arrays

PostPosted: Sat Aug 10, 2019 9:31 am
by _mental_
Actually, it's pretty simple. I thing you could do it yourself. Made PR because I wasn't sure about its inclusion in upcoming release.

Re: Append() for Dynamic Arrays

PostPosted: Sat Aug 10, 2019 11:41 am
by Graf Zahl
No need to delay this.

Re: Append() for Dynamic Arrays

PostPosted: Mon Aug 12, 2019 1:29 pm
by Apeirogon
That not what I meant. I mint "why you need to append several arrays into one?"

Re: Append() for Dynamic Arrays

PostPosted: Mon Aug 12, 2019 1:32 pm
by Graf Zahl
Does it matter? It's merely an export of an already existing function.

Re: Append() for Dynamic Arrays

PostPosted: Mon Aug 12, 2019 2:05 pm
by Apeirogon
Just curious.

Re: Append() for Dynamic Arrays

PostPosted: Mon Aug 12, 2019 7:07 pm
by Major Cooke
Because otherwise, you have to repeat code and it gets messy.