util/indices: move duplicated assignments out of switch cases