Material instances slow down when using static switches inside functions

I’ve noticed recently that using functions with static switches wrapped inside them drastically slows down performance in the material instance editor - essentially making sliders unusable. But if you have switches outside of the function it makes no difference - any idea why this is?