Skip to content

Commit 86929ff

Browse files
authored
Merge pull request #5124 from drewster99/bugfix/issue5123
Improves build time by 30%, resolving issue 5123 "Charts Framework takes a long time to build"
2 parents 953011d + c7f6ad9 commit 86929ff

File tree

2 files changed

+31
-6
lines changed

2 files changed

+31
-6
lines changed

Charts.xcodeproj/project.pbxproj

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1038,7 +1038,8 @@
10381038
DYLIB_COMPATIBILITY_VERSION = 1;
10391039
DYLIB_CURRENT_VERSION = 1;
10401040
DYLIB_INSTALL_NAME_BASE = "@rpath";
1041-
ENABLE_MODULE_VERIFIER = YES;
1041+
EAGER_LINKING = YES;
1042+
ENABLE_MODULE_VERIFIER = NO;
10421043
ENABLE_STRICT_OBJC_MSGSEND = YES;
10431044
FRAMEWORK_VERSION = A;
10441045
GCC_NO_COMMON_BLOCKS = YES;
@@ -1055,12 +1056,14 @@
10551056
MODULE_VERIFIER_SUPPORTED_LANGUAGES = "objective-c objective-c++";
10561057
MODULE_VERIFIER_SUPPORTED_LANGUAGE_STANDARDS = "gnu99 gnu++11";
10571058
MTL_ENABLE_DEBUG_INFO = YES;
1059+
OTHER_SWIFT_FLAGS = "-Xfrontend -warn-long-expression-type-checking=50";
10581060
PRODUCT_BUNDLE_IDENTIFIER = com.dcg.Charts;
10591061
PRODUCT_NAME = "$(TARGET_NAME)";
10601062
SDKROOT = macosx;
10611063
SKIP_INSTALL = YES;
10621064
SUPPORTED_PLATFORMS = "macosx iphoneos iphonesimulator appletvos appletvsimulator";
10631065
SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG;
1066+
SWIFT_COMPILATION_MODE = singlefile;
10641067
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
10651068
SWIFT_VERSION = 5.0;
10661069
TVOS_DEPLOYMENT_TARGET = 12.0;
@@ -1231,6 +1234,7 @@
12311234
DYLIB_COMPATIBILITY_VERSION = 1;
12321235
DYLIB_CURRENT_VERSION = 1;
12331236
DYLIB_INSTALL_NAME_BASE = "@rpath";
1237+
EAGER_LINKING = YES;
12341238
ENABLE_MODULE_VERIFIER = YES;
12351239
ENABLE_STRICT_OBJC_MSGSEND = YES;
12361240
FRAMEWORK_VERSION = A;
@@ -1248,6 +1252,7 @@
12481252
MODULE_VERIFIER_SUPPORTED_LANGUAGES = "objective-c objective-c++";
12491253
MODULE_VERIFIER_SUPPORTED_LANGUAGE_STANDARDS = "gnu99 gnu++11";
12501254
MTL_ENABLE_DEBUG_INFO = NO;
1255+
OTHER_SWIFT_FLAGS = "-Xfrontend -warn-long-expression-type-checking=50";
12511256
PRODUCT_BUNDLE_IDENTIFIER = com.dcg.Charts;
12521257
PRODUCT_NAME = "$(TARGET_NAME)";
12531258
SDKROOT = macosx;

Source/Charts/Animation/ChartAnimationEasing.swift

Lines changed: 25 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)