Patch D443 is a proposition for a new implementation of the Array Modifier, that does not use BMesh.
Modifiers using BMesh have very poor performance.
This patch is a proposed new implementation. It is identical in its features and results. It gives a performance improvement of more than 100 fold and more when merge option is not selected, and of around 10-20 with merge option checked. These improvements are measured without OpenMP, another /2 or /4 factor could be gained through multi-threading, which is much easier to implemement on the simple loops of direct derived mesh processing.
In this patch is a proposed implementation of doubles detection that is inspired from the algorithm used in the "Remove Doubles" operator, but with a few differences, using separate sorted arrays for target and source, and I think a slightly improved performance. This map_doubles() function could be added to cdderivedmesh.c, and made available to other modifiers.
The new implementation of the array modifier also uses CDDM_merge_verts() from cdderivedmesh.c, which up until now was only called by the mirror modifier.
I understand there is some risk in overhauling such rock-solid old work horse as the array modifier, but a 100 times gain is a lot, I believe it's definitely worth it, it can be the difference between a 10 seconds wait and a 0.1 second result.
Although the implementation is fully functionnal and has been tested in various conditions, it is meant for evaluation purposes only at this time. Depending on the "count" value of modifier, it will call the former implementation (for odd count values), or the new implementation (for even count values). It will also print the delay to console so that one can compare both implementations.
I have another refinement in mind, where the mapping of doubles performed at rank n of the array would be cached and re-applied with an offset at rank n+1. This would approximately cut time by half when merge is on.
One last word: the doubles mapping algorithm, very much inspired from the remove doubles operator and slightly improved, uses a sorted array of vertices according to the sum of x+y+z. Then candidate doubles are tested from within -3d to +3d of a given vertex. Actually 3 could be replaced by sqrt(3), or ~1.74, which is a (admittedly minor) optimization that could be put into remove doubles operator as well.