Fix optimizer performance regression