Note that it would be much faster to combine the binary indexes. (basically a merged of b+trees, at worst a merge sort).
Code for that would be nice in package chm, to keep it IDE independent. In theory you could write out that combined index even, there is even a (MS) extension for that; .CHW which is a modified chm variant.