Advertisement Jump to content
Sign in to follow this  
SquareDanceSteve

[.net] vb.net Redim Preserve Efficientcy?

This topic is 4913 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Advertisement
I presume you're trying to grow an array that turned out to be too small for your needs. Arrays are meant to be fixed in size, don't let VB fool you. If you need a growable array, use an ArrayList or any of the other System.Collections.

Share this post


Link to post
Share on other sites
I suppose it depends on the number of array elements and the memory consumption of each element.

Share this post


Link to post
Share on other sites
Don't Redim each time you add a ship, Redim a big chunk like 100 more than you need, then when you fill that array Redim it to be 100 larger. This will work a lot faster.

Share this post


Link to post
Share on other sites
Quote:
Original post by Stru
Don't Redim each time you add a ship, Redim a big chunk like 100 more than you need, then when you fill that array Redim it to be 100 larger. This will work a lot faster.


Or better yet, use System.Collections.ArrayList, since it will already do that for you.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!