Improved the performance of arraydb.to.arrayr

which is also used in lk