Swift type checking takes 110ms on simple Int() cast

281 Views Asked by At

My Xcode project takes ages to build so I have looked at expression that takes a long time.

The line

let timeStamp = Int(Date().timeIntervalSince1970)

takes 110ms. I have tried

let timeStamp : Int = Int(Date().timeIntervalSince1970)

which doesn't help. What else can I do to speed up Int casts or am I doing something wrong?

Also, UInt8 to Int takes a lot of time and Int to Int64 too. Basically everything that has to do with an Int takes a lot of time. Even Strings seem to be less compile-hungry.

Another example is

let t = CGFloat(Float(arc4random()) / Float(UINT32_MAX)) - 56ms

0

There are 0 best solutions below