Append() for Dynamic Arrays

Moderator: GZDoom Developers

Post Reply
User avatar
Major Cooke
Posts: 8170
Joined: Sun Jan 28, 2007 3:55 pm
Preferred Pronouns: He/Him
Location: QZDoom Maintenance Team

Append() for Dynamic Arrays

Post 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.
User avatar
Apeirogon
Posts: 1605
Joined: Mon Jun 12, 2017 12:57 am

Re: Append() for Dynamic Arrays

Post 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?
User avatar
Major Cooke
Posts: 8170
Joined: Sun Jan 28, 2007 3:55 pm
Preferred Pronouns: He/Him
Location: QZDoom Maintenance Team

Re: Append() for Dynamic Arrays

Post 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.
User avatar
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

Post by Matt »

Also makes the code a lot easier to read if we're not having to set up for loops each time.
User avatar
Major Cooke
Posts: 8170
Joined: Sun Jan 28, 2007 3:55 pm
Preferred Pronouns: He/Him
Location: QZDoom Maintenance Team

Re: Append() for Dynamic Arrays

Post by Major Cooke »

The biggest boon on top of that is the performance optimization.
_mental_
 
 
Posts: 3812
Joined: Sun Aug 07, 2011 4:32 am

Re: Append() for Dynamic Arrays

Post by _mental_ »

User avatar
Major Cooke
Posts: 8170
Joined: Sun Jan 28, 2007 3:55 pm
Preferred Pronouns: He/Him
Location: QZDoom Maintenance Team

Re: Append() for Dynamic Arrays

Post by Major Cooke »

Oooh, thank you! :mrgreen:
_mental_
 
 
Posts: 3812
Joined: Sun Aug 07, 2011 4:32 am

Re: Append() for Dynamic Arrays

Post 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.
User avatar
Graf Zahl
Lead GZDoom+Raze Developer
Lead GZDoom+Raze Developer
Posts: 49056
Joined: Sat Jul 19, 2003 10:19 am
Location: Germany

Re: Append() for Dynamic Arrays

Post by Graf Zahl »

No need to delay this.
User avatar
Apeirogon
Posts: 1605
Joined: Mon Jun 12, 2017 12:57 am

Re: Append() for Dynamic Arrays

Post by Apeirogon »

That not what I meant. I mint "why you need to append several arrays into one?"
User avatar
Graf Zahl
Lead GZDoom+Raze Developer
Lead GZDoom+Raze Developer
Posts: 49056
Joined: Sat Jul 19, 2003 10:19 am
Location: Germany

Re: Append() for Dynamic Arrays

Post by Graf Zahl »

Does it matter? It's merely an export of an already existing function.
User avatar
Apeirogon
Posts: 1605
Joined: Mon Jun 12, 2017 12:57 am

Re: Append() for Dynamic Arrays

Post by Apeirogon »

Just curious.
User avatar
Major Cooke
Posts: 8170
Joined: Sun Jan 28, 2007 3:55 pm
Preferred Pronouns: He/Him
Location: QZDoom Maintenance Team

Re: Append() for Dynamic Arrays

Post by Major Cooke »

Because otherwise, you have to repeat code and it gets messy.
Post Reply

Return to “Closed Feature Suggestions [GZDoom]”