ArrayList vs Arrays - Performance

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I wish to build up a byte array from various sources of different lengths. I
can either use a byte array and redimension it as needed as I add the various
values or use an arraylist which automatically expands as required then
convert it to an array after I finish adding the elements. Does anyone know
which would be faster considering that I would probably have about 10 redim
statements if I use a byte array. Microsoft's literature suggests using an
arraylist would be better but I don't always trust M'soft.
 
Dennis,
Does anyone know
which would be faster considering that I would probably have about 10 redim
statements if I use a byte array.

Can't you allocate a byte array that is larger than you initially
need, to reduce the number of ReDims?

I'd avoid ArrayList when working with bytes due to the boxing
overhead.



Mattias
 
What is "boxing overhead"?

Mattias Sjögren said:
Dennis,


Can't you allocate a byte array that is larger than you initially
need, to reduce the number of ReDims?

I'd avoid ArrayList when working with bytes due to the boxing
overhead.



Mattias
 
Dennis,
Microsoft's literature suggests using an arraylist would be better
but I don't always trust M'soft.

Why do you have doubts in the case of the arraylist.

It is a list that adds a reference against redimmension a complete array.

When you have doubts about that than you would start in my opinion as well
checking if a multiply operator is faster than a repeated add.

Just my thought,

Cor
 
Back
Top