Array.concat
or Array.append
, according to the documentation, allocate a new array then copy the content of the two initial arrays in the later.
List.append
complexity is proportional to the length of the first argument only.
So using list should theoretically be more efficient as your last array concatenation would anyway have the same complexity as the final Array.of_list
operation.
edit : As @coredump mentionned, keeping a tree of arrays, which would represent the logical concatenation of all arrays, would be the cheaper structures, and if you nead an actual array at the end, you could then compute the overall size of your "abstract" array, create an array of this size, and then fill it with the content of the tree of array. The operation would be linear in the size of the final array.
This being said, I doubt that it will make a big difference at the end unless you have huge expression to compile. In wich case you should also pay attention to the fact that List.append
is not tail recursive and thus might leads to stack overflow on (really) big lists.