Backport one change from !89 (closed) which is to fill the input vector using an STL algorithm instead of a simple loop, as this gives a nice speed improvement. The rest of that MR, to replace virtual methods with type erasure, is on hold as currently is slower (based on gcc 4.9).