Append() for Dynamic Arrays
Moderator: GZDoom Developers
- Major Cooke
- Posts: 8175
- Joined: Sun Jan 28, 2007 3:55 pm
- Preferred Pronouns: He/Him
- Location: QZDoom Maintenance Team
Append() for Dynamic Arrays
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.
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
Just curious, why you need to do this?A function that copies all the data of another array and puts it on the tail end of the calling array
- Major Cooke
- Posts: 8175
- Joined: Sun Jan 28, 2007 3:55 pm
- Preferred Pronouns: He/Him
- Location: QZDoom Maintenance Team
Re: Append() for Dynamic Arrays
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.
- Matt
- Posts: 9696
- Joined: Sun Jan 04, 2004 5:37 pm
- Preferred Pronouns: They/Them
- Operating System Version (Optional): Debian Bullseye
- Location: Gotham City SAR, Wyld-Lands of the Lotus People, Dominionist PetroConfederacy of Saudi Canadia
- Contact:
Re: Append() for Dynamic Arrays
Also makes the code a lot easier to read if we're not having to set up for loops each time.
- Major Cooke
- Posts: 8175
- Joined: Sun Jan 28, 2007 3:55 pm
- Preferred Pronouns: He/Him
- Location: QZDoom Maintenance Team
Re: Append() for Dynamic Arrays
The biggest boon on top of that is the performance optimization.
- Major Cooke
- Posts: 8175
- Joined: Sun Jan 28, 2007 3:55 pm
- Preferred Pronouns: He/Him
- Location: QZDoom Maintenance Team
Re: Append() for Dynamic Arrays
Oooh, thank you!
Re: Append() for Dynamic Arrays
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.
- Graf Zahl
- Lead GZDoom+Raze Developer
- Posts: 49067
- Joined: Sat Jul 19, 2003 10:19 am
- Location: Germany
Re: Append() for Dynamic Arrays
No need to delay this.
Re: Append() for Dynamic Arrays
That not what I meant. I mint "why you need to append several arrays into one?"
- Graf Zahl
- Lead GZDoom+Raze Developer
- Posts: 49067
- Joined: Sat Jul 19, 2003 10:19 am
- Location: Germany
Re: Append() for Dynamic Arrays
Does it matter? It's merely an export of an already existing function.
Re: Append() for Dynamic Arrays
Just curious.
- Major Cooke
- Posts: 8175
- Joined: Sun Jan 28, 2007 3:55 pm
- Preferred Pronouns: He/Him
- Location: QZDoom Maintenance Team
Re: Append() for Dynamic Arrays
Because otherwise, you have to repeat code and it gets messy.