I’ve been reading about dynamic arrays in C. Fun bed time reading right? It has got me thinking about arrays in Xojo however.
Let’s say I have a need for a dynamically-growable array of
// Define Var bytes() As UInt8 // Add a new byte bytes.AddRow(10)
Is it more performant to allocate a certain amount of elements up front (accepting that uses more memory) and insert into an empty index or call
// Sloppy code but you get the gist. Var bytes(1000) As UInt8 Var pos As Integer = 0 Var lastIndex As Integer = 999 bytes(pos) = 10 pos = pos + 1 If pos > lastIndex Then bytes.ResizeTo(2000) lastIndex = 1999 End If