About adding items in bulk in a Listview Control

While looking for ways to speed up loading data into a ListView, I compared the two current approaches using benchmarks. The old one adds items one by one and then fills each column individually, while the newer one uses a multidimensional Vector and loads the whole batch in a single call. To my surprise, the difference is quite significant: the new method can be up to three times faster when populating data!, which really matters when dealing with large lists. Even when adding items one by one in order to also set the associated data value, the difference is noticeable.

The problem is that, in practice (at least in my case), it's not very common to already have the data in an array or vector form. Most of the time, it's way much more convenient to manage data using named properties, either through JScript objects or Opus Maps. That makes the data easier to reuse elsewhere, since it's not only meant to be displayed in a ListView. Referring to a property like xyz by name is far clearer and safer than relying on a vector where you need to remember the position of each value.

This made me think about a possible improvement. Instead of continuing to extend AddItem() and making its usage more confusing, it might make sense to introduce a new method like AddItems(), specifically designed for bulk loading. This method could accept JScript objects or even Maps (an object containing objects, or a map containing maps).

Along with that, there could be a DefineColumns() method, where each column is explicitly bound to a property name. That way, when AddItems() is called, it already knows which property goes into which column. The value for the main column could also be defined there, treated as just another property of the object or map. Even the associated data could be there too.

Using multidimensional arrays works fine when the data is read-only, but when that's not the case, you end up creating those arrays solely for the purpose of feeding the ListView, and then keeping them in sync whenever the data changes, which is, IMHO, redundant.

Thanks for considering it.