speedup invert

Improve the performance of `_.invert`.

Just like `_.values` and `_.pairs`.