Generalize the small inplace scan function.