Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improves build time by 30%, resolving issue 5123 "Charts Framework takes a long time to build" #5124

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions Charts.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
archiveVersion = 1;
classes = {
};
objectVersion = 53;
objectVersion = 54;
objects = {

/* Begin PBXBuildFile section */
Expand Down Expand Up @@ -1034,7 +1034,8 @@
DYLIB_COMPATIBILITY_VERSION = 1;
DYLIB_CURRENT_VERSION = 1;
DYLIB_INSTALL_NAME_BASE = "@rpath";
ENABLE_MODULE_VERIFIER = YES;
EAGER_LINKING = YES;
ENABLE_MODULE_VERIFIER = NO;
ENABLE_STRICT_OBJC_MSGSEND = YES;
FRAMEWORK_VERSION = A;
GCC_NO_COMMON_BLOCKS = YES;
Expand All @@ -1051,12 +1052,14 @@
MODULE_VERIFIER_SUPPORTED_LANGUAGES = "objective-c objective-c++";
MODULE_VERIFIER_SUPPORTED_LANGUAGE_STANDARDS = "gnu99 gnu++11";
MTL_ENABLE_DEBUG_INFO = YES;
OTHER_SWIFT_FLAGS = "-Xfrontend -warn-long-expression-type-checking=50";
PRODUCT_BUNDLE_IDENTIFIER = com.dcg.Charts;
PRODUCT_NAME = "$(TARGET_NAME)";
SDKROOT = macosx;
SKIP_INSTALL = YES;
SUPPORTED_PLATFORMS = "macosx iphoneos iphonesimulator appletvos appletvsimulator";
SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG;
SWIFT_COMPILATION_MODE = singlefile;
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
SWIFT_VERSION = 5.0;
TVOS_DEPLOYMENT_TARGET = 12.0;
Expand Down Expand Up @@ -1227,6 +1230,7 @@
DYLIB_COMPATIBILITY_VERSION = 1;
DYLIB_CURRENT_VERSION = 1;
DYLIB_INSTALL_NAME_BASE = "@rpath";
EAGER_LINKING = YES;
ENABLE_MODULE_VERIFIER = YES;
ENABLE_STRICT_OBJC_MSGSEND = YES;
FRAMEWORK_VERSION = A;
Expand All @@ -1244,6 +1248,7 @@
MODULE_VERIFIER_SUPPORTED_LANGUAGES = "objective-c objective-c++";
MODULE_VERIFIER_SUPPORTED_LANGUAGE_STANDARDS = "gnu99 gnu++11";
MTL_ENABLE_DEBUG_INFO = NO;
OTHER_SWIFT_FLAGS = "-Xfrontend -warn-long-expression-type-checking=50";
PRODUCT_BUNDLE_IDENTIFIER = com.dcg.Charts;
PRODUCT_NAME = "$(TARGET_NAME)";
SDKROOT = macosx;
Expand Down
30 changes: 25 additions & 5 deletions Source/Charts/Animation/ChartAnimationEasing.swift
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,12 @@ internal struct EasingFunctions
}

position = position - 1.0
return Double( 0.5 * (-pow(2.0, -10.0 * position) + 2.0) )

// compute partial result so Xcode's type-checker doesn't take too long
let partialResult: Double = -pow(2.0, -10.0 * position) + 2.0

// took 120ms to type check before breaking out partial result, above
return Double( 0.5 * partialResult )
}

internal static let EaseInCirc = { (elapsed: TimeInterval, duration: TimeInterval) -> Double in
Expand All @@ -265,12 +270,17 @@ internal struct EasingFunctions

internal static let EaseInOutCirc = { (elapsed: TimeInterval, duration: TimeInterval) -> Double in
var position: TimeInterval = elapsed / (duration / 2.0)

// calculate partial result so Swift compiler doesn't lose its mind
let sqrtPartialResult: Double = sqrt(1.0 - position * position)
if position < 1.0
{
return Double( -0.5 * (sqrt(1.0 - position * position) - 1.0) )
// was 800ms to type check with inlined sqrt calculation, from above
return Double( -0.5 * (sqrtPartialResult - 1.0) )
}
position -= 2.0
return Double( 0.5 * (sqrt(1.0 - position * position) + 1.0) )
// was 1500ms to type check with inlined sqrt calculation, from above
return Double( 0.5 * (sqrtPartialResult + 1.0) )
}

internal static let EaseInElastic = { (elapsed: TimeInterval, duration: TimeInterval) -> Double in
Expand Down Expand Up @@ -328,13 +338,23 @@ internal struct EasingFunctions
return Double( -0.5 * (pow(2.0, 10.0 * position) * sin((position * duration - s) * (2.0 * Double.pi) / p)) )
}
position -= 1.0
return Double( pow(2.0, -10.0 * position) * sin((position * duration - s) * (2.0 * Double.pi) / p) * 0.5 + 1.0 )

// Break out partial result so the Swift compiler doesn't lose its mind
let sinPartialResult: Double = sin((position * duration - s) * (2.0 * Double.pi) / p)

// Original expression here, with the expression above inlined, took 600ms to type check
return Double( pow(2.0, -10.0 * position) * sinPartialResult * 0.5 + 1.0 )
}

internal static let EaseInBack = { (elapsed: TimeInterval, duration: TimeInterval) -> Double in
let s: TimeInterval = 1.70158
var position: TimeInterval = elapsed / duration
return Double( position * position * ((s + 1.0) * position - s) )

// Break out partial result so the Swift compiler doesn't lose its mind
let partialResult: Double = ((s + 1.0) * position - s)

// Original expression here, with partialResult inlined, took 260ms to type check
return Double( position * position * partialResult )
}

internal static let EaseOutBack = { (elapsed: TimeInterval, duration: TimeInterval) -> Double in
Expand Down