With: let nbrBytes = 400_000_000 let localArray = UnsafeMutablePointer<UInt8>.allocate(capacity: nbrBytes) // touch every page before summing: for i in 0 ..< nbrBytes / 4096 { localArray[ 4096 * i ] = 1 }
This rather innocent loop: var count: UInt64 = 0 for index in 0 ..< loopLimit { count += UInt64( localArray[ Int(index) ] ) } takes 2.4 times as long if preceded by: let loopLimit = UInt64(nbrBytes) compared to: let loopLimit = Int(nbrBytes) Why can’t Swift iterate in UInt64 as efficient as with Int? Any real issue here which I am overlooking or just a compiler bug? Gerriet. _______________________________________________ swift-users mailing list swift-users@swift.org https://lists.swift.org/mailman/listinfo/swift-users