SWIFT Xcode 7.3 really slows down compilation time by creating a specific method

I am trying to make compilation time of my project faster. I have read here and other online resources.
My project build settings look right:

  • Optimization None (debug only)
  • Only for active YES architecture
  • Compile DWARF

It seems that the compiler slows down when it needs to infer a type using a nice method, for example string.characters.split{}.map{}, and when it needs to add arrays using an operator +.
Using these tips, I reduced the compilation time, but there is this method that takes about 6 seconds on the latest model of my MBP 15 machine, I really can not understand why.
Here is a fragment of the track:

6102.4ms /../ Views / CakeView.swift: 221: 10 func changeArrowDirection (direction: ArrowDirection, animated: Bool = default)
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
    }

Can anyone identify the cause?

+4
source share

All Articles