quick array question

I see that there are a few options for creating arrays in Servoy developer, such as

new Array()
new Array(number)

It seems you don’t need to specify the size of an array when you create it, but is it better to if you can? The method would need to look at the database to find out the size the array should be.
I’m creating a method to manipulate some arrays. I could eliminate some lines of code if I don’t specify the size of the array, but would that be wasting memory or cpu cycles?
In other words, is it more efficient to do

numberOfItems = databaseManager.getFoundSetCount(foundset);
new myArray(numberOfItems);
myArray = databaseManager.getFoundSetDataProviderAsArray(foundset,'item1');

or just

new myArray()
myArray = databaseManager.getFoundSetDataProviderAsArray(foundset,'item1');

?

Users may run this method many times and, obviously, I want the users to see as little delay as possible.

Hi Adam,

Since databaseManager.getFoundSetDataProviderAsArray() creates and returns an array object you can simply do this:

var myArray = databaseManager.getFoundSetDataProviderAsArray(foundset,'item1');

Hope this helps.

That’s a good idea. I wish I had thought of it. If creating an array that way specifies the size of the array, then it would seem to be the most efficient way to do it.
I’ll do it that way. Thanks.