我试图更快地完成项目的编译时间。我已阅读here和其他在线资源 我的项目构建设置似乎是正确的:
当需要在非常链接的方法中推断类型时,例如string.characters.split{}.map{}
以及需要使用+
运算符添加数组时,编译器似乎会变慢。
使用这些建议我减少了编译时间,但这种方法在我的机器MBP 15'上花了大约6秒钟。最后一个模型,我真的无法弄清楚原因。
这里有一条痕迹:
6102.4ms /../Views/CakeView.swift:221:10 func changeArrowDirection(方向:ArrowDirection,动画:Bool = 默认)
2463.5ms /../Views/CakeView.swift:71:9 final didSet {}
2189.8ms /../UIComponents/GradientView.swift:47:9 final didSet {}
func changeArrowDirection(direction: ArrowDirection, animated: Bool = false) {
let radius: CGFloat = min(bounds.size.width / 2.0, bounds.size.height / 2.0)
let arrowBackgroundLayerRadius: CGFloat = radius / 2.0
let tailWidth: CGFloat = arrowBackgroundLayerRadius / 4.0
let headWidth: CGFloat = arrowBackgroundLayerRadius / 1.75
let headlength: CGFloat = arrowBackgroundLayerRadius / 2.0
let subArc: CGFloat = cos(asin(1.0 / (2.0 * arrowBackgroundLayerRadius)))
let startPoint: CGPoint
let endPoint: CGPoint
switch direction {
case .Up:
startPoint = CGPoint(x: bounds.size.width / 2.0, y: bounds.size.height / 2.5 + arrowBackgroundLayerRadius - arrowBorderWidth - subArc - arrowCircleBorderWidth)
endPoint = CGPoint(x: bounds.size.width / 2.0, y: bounds.size.height / 1.75 - arrowBackgroundLayerRadius + arrowCircleBorderWidth + arrowBorderWidth)
case .Down:
startPoint = CGPoint(x: bounds.size.width / 2.0, y: bounds.size.height / 1.75 - arrowBackgroundLayerRadius + arrowBorderWidth + subArc + arrowCircleBorderWidth)
endPoint = CGPoint(x: bounds.size.width / 2.0, y: bounds.size.height / 2.5 + arrowBackgroundLayerRadius - arrowCircleBorderWidth - arrowBorderWidth)
case .Left:
startPoint = CGPoint(x: bounds.size.width / 2.0 - arrowBackgroundLayerRadius + arrowBorderWidth + subArc + arrowCircleBorderWidth, y: bounds.size.height / 2.0)
endPoint = CGPoint(x: bounds.size.width / 2.0 + arrowBackgroundLayerRadius - arrowCircleBorderWidth - arrowBorderWidth,y: bounds.size.height / 2.0)
case .Right:
startPoint = CGPoint(x: bounds.size.width / 2.0 + arrowBackgroundLayerRadius - arrowBorderWidth - subArc - arrowCircleBorderWidth, y: bounds.size.height / 2.0)
endPoint = CGPoint(x: bounds.size.width / 2.0 - arrowBackgroundLayerRadius + arrowCircleBorderWidth + arrowBorderWidth,y: bounds.size.height / 2.0)
}
arrowLayer.path = UIBezierPath.bezierPathWithArrowFromPoint(startPoint, endPoint: endPoint, tailWidth: tailWidth, headWidth: headWidth, headLength: headlength).CGPath
}
有人能发现原因吗?