Optimizes selection of dimnames to avoid copying