mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
[String] Speed up constant factors on comparison.
Include some tuning and tweaking to reduce the constant factors involved in string comparison. This yields considerable improvement on our micro-benchmarks, and allows us to make less inlinable code and have a smaller ABI surface area. Adds more extensive testing of corner cases in our existing fast-paths.
This commit is contained in:
@@ -153,18 +153,11 @@ extension _StringGuts {
|
||||
|
||||
@inlinable @inline(__always)
|
||||
internal func withFastUTF8<R>(
|
||||
range: Range<Int>?,
|
||||
range: Range<Int>,
|
||||
_ f: (UnsafeBufferPointer<UInt8>) throws -> R
|
||||
) rethrows -> R {
|
||||
return try self.withFastUTF8 { wholeUTF8 in
|
||||
let slicedUTF8: UnsafeBufferPointer<UInt8>
|
||||
if let r = range {
|
||||
slicedUTF8 = UnsafeBufferPointer(rebasing: wholeUTF8[r])
|
||||
} else {
|
||||
slicedUTF8 = wholeUTF8
|
||||
}
|
||||
|
||||
return try f(slicedUTF8)
|
||||
return try f(UnsafeBufferPointer(rebasing: wholeUTF8[range]))
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user