improved memory layout for calculate_region_generic
optimization vector preparations