Skip to content

Commit ab36b51

Browse files
committed
[stdlib] Make some trivial Substring methods inlinable
1 parent 3f39d7e commit ab36b51

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

stdlib/public/core/Substring.swift

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -199,8 +199,9 @@ extension Substring: StringProtocol {
199199
return _slice.distance(from: start, to: end)
200200
}
201201

202+
@inlinable
202203
public subscript(i: Index) -> Character {
203-
return _slice[i]
204+
@inline(__always) get { return _slice[i] }
204205
}
205206

206207
public mutating func replaceSubrange<C>(
@@ -402,12 +403,15 @@ extension Substring.UTF8View : BidirectionalCollection {
402403
_slice._failEarlyRangeCheck(range, bounds: bounds)
403404
}
404405

406+
@inlinable
405407
public func index(before i: Index) -> Index { return _slice.index(before: i) }
406408

409+
@inlinable
407410
public func formIndex(before i: inout Index) {
408411
_slice.formIndex(before: &i)
409412
}
410413

414+
@inlinable
411415
public subscript(r: Range<Index>) -> Substring.UTF8View {
412416
// FIXME(strings): tests.
413417
_precondition(r.lowerBound >= startIndex && r.upperBound <= endIndex,
@@ -804,5 +808,3 @@ extension Substring {
804808
return Substring(_slice[r])
805809
}
806810
}
807-
808-

0 commit comments

Comments
 (0)