Re-instate "stdlib: Add some inlining attributes to help the optimizer getting the right inlining decisions."

This re-instates commit 8b0e36779e
This commit is contained in:
Erik Eckstein
2016-03-29 15:47:53 -07:00
parent a95979bdd2
commit c0964a492d
5 changed files with 51 additions and 19 deletions

View File

@@ -307,22 +307,25 @@ public struct _StringCore {
/// Get the Nth UTF-16 Code Unit stored.
public subscript(position: Int) -> UTF16.CodeUnit {
_precondition(
position >= 0,
"subscript: index precedes String start")
@inline(__always)
get {
_precondition(
position >= 0,
"subscript: index precedes String start")
_precondition(
position <= count,
"subscript: index points past String end")
_precondition(
position <= count,
"subscript: index points past String end")
if _fastPath(_baseAddress != nil) {
return _nthContiguous(position)
}
if _fastPath(_baseAddress != nil) {
return _nthContiguous(position)
}
#if _runtime(_ObjC)
return _cocoaStringSubscript(self, position)
return _cocoaStringSubscript(self, position)
#else
_sanityCheckFailure("subscript: non-native string without objc runtime")
_sanityCheckFailure("subscript: non-native string without objc runtime")
#endif
}
}
/// Write the string, in the given encoding, to output.
@@ -519,6 +522,7 @@ public struct _StringCore {
_invariantCheck()
}
@inline(never)
mutating func append(rhs: _StringCore) {
_invariantCheck()
let minElementWidth