@@ -249,7 +249,12 @@ internal struct EasingFunctions
249249 }
250250
251251 position = position - 1.0
252- return Double ( 0.5 * ( - pow( 2.0 , - 10.0 * position) + 2.0 ) )
252+
253+ // compute partial result so Xcode's type-checker doesn't take too long
254+ let partialResult : Double = - pow( 2.0 , - 10.0 * position) + 2.0
255+
256+ // took 120ms to type check before breaking out partial result, above
257+ return Double ( 0.5 * partialResult )
253258 }
254259
255260 internal static let EaseInCirc = { ( elapsed: TimeInterval , duration: TimeInterval ) -> Double in
@@ -265,12 +270,17 @@ internal struct EasingFunctions
265270
266271 internal static let EaseInOutCirc = { ( elapsed: TimeInterval , duration: TimeInterval ) -> Double in
267272 var position : TimeInterval = elapsed / ( duration / 2.0 )
273+
274+ // calculate partial result so Swift compiler doesn't lose its mind
275+ let sqrtPartialResult : Double = sqrt ( 1.0 - position * position)
268276 if position < 1.0
269277 {
270- return Double ( - 0.5 * ( sqrt ( 1.0 - position * position) - 1.0 ) )
278+ // was 800ms to type check with inlined sqrt calculation, from above
279+ return Double ( - 0.5 * ( sqrtPartialResult - 1.0 ) )
271280 }
272281 position -= 2.0
273- return Double ( 0.5 * ( sqrt ( 1.0 - position * position) + 1.0 ) )
282+ // was 1500ms to type check with inlined sqrt calculation, from above
283+ return Double ( 0.5 * ( sqrtPartialResult + 1.0 ) )
274284 }
275285
276286 internal static let EaseInElastic = { ( elapsed: TimeInterval , duration: TimeInterval ) -> Double in
@@ -328,13 +338,23 @@ internal struct EasingFunctions
328338 return Double ( - 0.5 * ( pow ( 2.0 , 10.0 * position) * sin( ( position * duration - s) * ( 2.0 * Double. pi) / p) ) )
329339 }
330340 position -= 1.0
331- return Double ( pow ( 2.0 , - 10.0 * position) * sin( ( position * duration - s) * ( 2.0 * Double. pi) / p) * 0.5 + 1.0 )
341+
342+ // Break out partial result so the Swift compiler doesn't lose its mind
343+ let sinPartialResult : Double = sin ( ( position * duration - s) * ( 2.0 * Double. pi) / p)
344+
345+ // Original expression here, with the expression above inlined, took 600ms to type check
346+ return Double ( pow ( 2.0 , - 10.0 * position) * sinPartialResult * 0.5 + 1.0 )
332347 }
333348
334349 internal static let EaseInBack = { ( elapsed: TimeInterval , duration: TimeInterval ) -> Double in
335350 let s : TimeInterval = 1.70158
336351 var position : TimeInterval = elapsed / duration
337- return Double ( position * position * ( ( s + 1.0 ) * position - s) )
352+
353+ // Break out partial result so the Swift compiler doesn't lose its mind
354+ let partialResult : Double = ( ( s + 1.0 ) * position - s)
355+
356+ // Original expression here, with partialResult inlined, took 260ms to type check
357+ return Double ( position * position * partialResult )
338358 }
339359
340360 internal static let EaseOutBack = { ( elapsed: TimeInterval , duration: TimeInterval ) -> Double in
0 commit comments