I'm noticing that removeLast is very slow. Much slower than you'd expect for an O(1) removal algorithm (the constant would have to be huge).
Here's the code I'm using for a test:
var array = [ Int ]()
for i in 0..<262144 {
array.append(i)
}
print ("done appending") // we get here quickly
let n = array.count
for _ in 0..<n {
array.removeLast() // popLast is also slow
}
print ("done")
This takes 16 seconds on my machine. An equivalent C++ program takes .002 seconds.
Can you repro? Any idea what's going on there?
http://stackoverflow.com/questions/41816801/swift-array-removelast-extremely-slow