This paper considers the switching time optimization of time-varying linear switched systems subject to quadratic cost-also potentially time-varying. The problem is formulated so that only a single set of differential equations need to be solved prior to optimization. Once these differential equations have been solved, the cost may be minimized over arbitrary number of modes and mode sequences without requiring additional simulation. The number of matrix multiplications needed to compute the gradient grows linearly with respect to the number of switching times, resulting in fast execution even for high dimensional optimizations. Lastly, the differential equations that need to be simulated are as smooth as the system's vector fields, despite the fact that the optimization itself is nonsmooth. Examples illustrate the technique and its efficiency, including a comparison with other standard techniques.