Re: [swift-users] Help! Slicing an array is very expensive

2017-05-09 Thread Howard Lovatt via swift-users
Try: struct SegmentedArray { private static let segmentCapacityPowerOf2 = 13 private static let segmentCapacity = 1 << SegmentedArray.segmentCapacityPowerOf2 private var offset: Int private var firstSegments: [[UInt8]] private var lastSegment: [UInt8] var count: Int {

Re: [swift-users] Help! Slicing an array is very expensive

2017-05-09 Thread Michael Gottesman via swift-users
Could you file a bug report? bugs.swift.org? Michael > On May 9, 2017, at 12:59 AM, Howard Lovatt via swift-users > wrote: > > My mistake. If I create a new array I get the problem. EG: > > import Foundation > > func elapsed(s: DispatchTime, e: DispatchTime) -> Double { > return Double(e

Re: [swift-users] Help! Slicing an array is very expensive

2017-05-09 Thread Howard Lovatt via swift-users
My mistake. If I create a new array I get the problem. EG: import Foundation func elapsed(s: DispatchTime, e: DispatchTime) -> Double { return Double(e.uptimeNanoseconds - s.uptimeNanoseconds) / 1_000_000_000 } let s = 250_000_000 var a = [UInt8]() a.reserveCapacity(s) let sa = DispatchTime

Re: [swift-users] Help! Slicing an array is very expensive

2017-05-09 Thread Howard Lovatt via swift-users
I find trimming relative to appending OK on my 6 year old MacBook Pro. EG: import Foundation func elapsed(s: DispatchTime, e: DispatchTime) -> Double { return Double(e.uptimeNanoseconds - s.uptimeNanoseconds) / 1_000_000_000 } let s = 250_000_000 var a = [UInt8]() a.reserveCapacity(s) let s