Use same optimization and DRYification for getArray as well.