[Added] Append() for Dynamic Arrays

Moderator: GZDoom Developers

Append() for Dynamic Arrays

Postby Major Cooke » Fri Aug 09, 2019 10:48 am

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
Major Cooke
Do unto others as you would have unto you. Judge yourself first.
 
Joined: 28 Jan 2007

Re: Append() for Dynamic Arrays

Postby Apeirogon » Fri Aug 09, 2019 2:19 pm

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?
Apeirogon
I have a strange sense of humour
 
Joined: 12 Jun 2017

Re: Append() for Dynamic Arrays

Postby Major Cooke » Fri Aug 09, 2019 3:21 pm

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
Major Cooke
Do unto others as you would have unto you. Judge yourself first.
 
Joined: 28 Jan 2007

Re: Append() for Dynamic Arrays

Postby Matt » Fri Aug 09, 2019 7:00 pm

Also makes the code a lot easier to read if we're not having to set up for loops each time.
User avatar
Matt
Putting the XD into *xdeath since 2007
 
Joined: 04 Jan 2004
Location: Gotham City SAR, Wyld-Lands of the Lotus People, Dominionist PetroConfederacy of Saudi Canadia

Re: Append() for Dynamic Arrays

Postby Major Cooke » Sat Aug 10, 2019 7:30 am

The biggest boon on top of that is the performance optimization.
User avatar
Major Cooke
Do unto others as you would have unto you. Judge yourself first.
 
Joined: 28 Jan 2007

Re: Append() for Dynamic Arrays

Postby _mental_ » Sat Aug 10, 2019 8:39 am

_mental_
 
 
 
Joined: 07 Aug 2011

Re: Append() for Dynamic Arrays

Postby Major Cooke » Sat Aug 10, 2019 9:23 am

Oooh, thank you! :mrgreen:
User avatar
Major Cooke
Do unto others as you would have unto you. Judge yourself first.
 
Joined: 28 Jan 2007

Re: Append() for Dynamic Arrays

Postby _mental_ » Sat Aug 10, 2019 9:31 am

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.
_mental_
 
 
 
Joined: 07 Aug 2011

Re: Append() for Dynamic Arrays

Postby Graf Zahl » Sat Aug 10, 2019 11:41 am

No need to delay this.
User avatar
Graf Zahl
Lead GZDoom Developer
Lead GZDoom Developer
 
Joined: 19 Jul 2003
Location: Germany

Re: Append() for Dynamic Arrays

Postby Apeirogon » Mon Aug 12, 2019 1:29 pm

That not what I meant. I mint "why you need to append several arrays into one?"
Apeirogon
I have a strange sense of humour
 
Joined: 12 Jun 2017

Re: Append() for Dynamic Arrays

Postby Graf Zahl » Mon Aug 12, 2019 1:32 pm

Does it matter? It's merely an export of an already existing function.
User avatar
Graf Zahl
Lead GZDoom Developer
Lead GZDoom Developer
 
Joined: 19 Jul 2003
Location: Germany

Re: Append() for Dynamic Arrays

Postby Apeirogon » Mon Aug 12, 2019 2:05 pm

Just curious.
Apeirogon
I have a strange sense of humour
 
Joined: 12 Jun 2017

Re: Append() for Dynamic Arrays

Postby Major Cooke » Mon Aug 12, 2019 7:07 pm

Because otherwise, you have to repeat code and it gets messy.
User avatar
Major Cooke
Do unto others as you would have unto you. Judge yourself first.
 
Joined: 28 Jan 2007


Return to Closed Feature Suggestions

Who is online

Users browsing this forum: No registered users and 0 guests