mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
[gardening] Clean up many String computed vars
This commit is contained in:
@@ -121,19 +121,15 @@ extension String.UTF8View: BidirectionalCollection {
|
||||
/// nonempty.
|
||||
///
|
||||
/// If the UTF-8 view is empty, `startIndex` is equal to `endIndex`.
|
||||
@inlinable
|
||||
public var startIndex: Index {
|
||||
@inline(__always) get { return _guts.startIndex }
|
||||
}
|
||||
@inlinable @inline(__always)
|
||||
public var startIndex: Index { return _guts.startIndex }
|
||||
|
||||
/// The "past the end" position---that is, the position one
|
||||
/// greater than the last valid subscript argument.
|
||||
///
|
||||
/// In an empty UTF-8 view, `endIndex` is equal to `startIndex`.
|
||||
@inlinable
|
||||
public var endIndex: Index {
|
||||
@inline(__always) get { return _guts.endIndex }
|
||||
}
|
||||
@inlinable @inline(__always)
|
||||
public var endIndex: Index { return _guts.endIndex }
|
||||
|
||||
/// Returns the next consecutive position after `i`.
|
||||
///
|
||||
@@ -209,30 +205,26 @@ extension String.UTF8View: BidirectionalCollection {
|
||||
///
|
||||
/// - Parameter position: A valid index of the view. `position`
|
||||
/// must be less than the view's end index.
|
||||
@inlinable
|
||||
@inlinable @inline(__always)
|
||||
public subscript(i: Index) -> UTF8.CodeUnit {
|
||||
@inline(__always) get {
|
||||
String(_guts)._boundsCheck(i)
|
||||
if _fastPath(_guts.isFastUTF8) {
|
||||
return _guts.withFastUTF8 { utf8 in utf8[_unchecked: i._encodedOffset] }
|
||||
}
|
||||
|
||||
return _foreignSubscript(position: i)
|
||||
String(_guts)._boundsCheck(i)
|
||||
if _fastPath(_guts.isFastUTF8) {
|
||||
return _guts.withFastUTF8 { utf8 in utf8[_unchecked: i._encodedOffset] }
|
||||
}
|
||||
|
||||
return _foreignSubscript(position: i)
|
||||
}
|
||||
}
|
||||
|
||||
extension String.UTF8View: CustomStringConvertible {
|
||||
@inlinable
|
||||
public var description: String {
|
||||
@inline(__always) get { return String(String(_guts)) }
|
||||
}
|
||||
@inlinable @inline(__always)
|
||||
public var description: String { return String(_guts) }
|
||||
}
|
||||
|
||||
extension String.UTF8View: CustomDebugStringConvertible {
|
||||
public var debugDescription: String {
|
||||
return "UTF8View(\(self.description.debugDescription))"
|
||||
}
|
||||
public var debugDescription: String {
|
||||
return "UTF8View(\(self.description.debugDescription))"
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -289,14 +281,12 @@ extension String {
|
||||
}
|
||||
|
||||
extension String.UTF8View {
|
||||
@inlinable
|
||||
@inlinable @inline(__always)
|
||||
public var count: Int {
|
||||
@inline(__always) get {
|
||||
if _fastPath(_guts.isFastUTF8) {
|
||||
return _guts.count
|
||||
}
|
||||
return _foreignCount()
|
||||
if _fastPath(_guts.isFastUTF8) {
|
||||
return _guts.count
|
||||
}
|
||||
return _foreignCount()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user