The proposal aims to enhance the performance of the OutSystems built-in ListAppendAll function. Currently, ListAppendAll iterates over the source list using a foreach loop, invoking the ListAppend action on each iteration. This results in multiple dynamic array resizings, as each call to ListAppend extends the underlying array incrementally, leading to performance overhead due to repeated memory allocations and data copies.
In contrast, in native C#, the List.AddRange method optimises this process by pre-allocating the required space in the underlying array in a single operation. It then efficiently inserts elements using Array.Copy, minimising reallocations and improving execution time. Implementing a similar bulk append mechanism in ListAppendAll would reduce memory overhead and improve performance.
The attached files include the BenchmarkDotNet results and the code used for performance testing.
Tested on .NET 4.8.1 and Intel Core i7 12800HX processor.
While the code does not exactly replicate the OutSystems implementation, it follows a similar approach to demonstrate potential performance improvements.
2025_02_25_13_48_39__ConsoleApp_ListBenchMark[1].cs ConsoleApp_ListBenchMark.ListInsertBenchmark.html