Understanding the optimization of SWITCH

The SWITCH function in DAX has been optimized over the years, and it is helpful to know what makes the optimization work best.