Added an in-place version

This avoids the slice copies.