Consider capacity >= mincapacity the _fastPath in requestUniqueMutableBackingBuffer.

This should allow us to better optimize repeated push/pop benchmarks.

I didn't notice a performance change at the time I did this. I'm just
putting it in as a hopefully obvious drive-by fix.

Swift SVN r21429
This commit is contained in:
Andrew Trick
2014-08-23 01:31:07 +00:00
parent 3b9fe96e16
commit 125846a213
2 changed files with 7 additions and 2 deletions

View File

@@ -197,7 +197,10 @@ public struct _ContiguousArrayBuffer<T> : _ArrayBufferType {
public mutating func requestUniqueMutableBackingBuffer(minimumCapacity: Int)
-> _ContiguousArrayBuffer<Element>?
{
return isUniquelyReferenced() && capacity >= minimumCapacity ? self : nil
if _fastPath(isUniquelyReferenced() && capacity >= minimumCapacity) {
return self
}
return nil
}
public mutating func isMutableAndUniquelyReferenced() -> Bool {