only calculate offset index once. #12537