Skip to content

Commit bbb4fd5

Browse files
lorenteymilseman
authored andcommitted
_ValidUTF8Buffer: Fix warnings; implement isEmpty directly.
1 parent fd02406 commit bbb4fd5

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

stdlib/public/core/ValidUTF8Buffer.swift

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,12 @@ extension _ValidUTF8Buffer : Collection {
9999
public var count : Int {
100100
return Storage.bitWidth &>> 3 &- _biasedBits.leadingZeroBitCount &>> 3
101101
}
102-
102+
103+
@_inlineable // FIXME(sil-serialize-all)
104+
public var isEmpty : Bool {
105+
return _biasedBits == 0
106+
}
107+
103108
@_inlineable // FIXME(sil-serialize-all)
104109
public func index(after i: Index) -> Index {
105110
_debugPrecondition(i._biasedBits != 0)
@@ -122,7 +127,7 @@ extension _ValidUTF8Buffer : BidirectionalCollection {
122127
}
123128

124129
extension _ValidUTF8Buffer : RandomAccessCollection {
125-
public typealias Indices = DefaultRandomAccessIndices<_ValidUTF8Buffer>
130+
public typealias Indices = DefaultIndices<_ValidUTF8Buffer>
126131

127132
@_inlineable // FIXME(sil-serialize-all)
128133
@inline(__always)
@@ -172,9 +177,12 @@ extension _ValidUTF8Buffer : RangeReplaceableCollection {
172177

173178
@_inlineable // FIXME(sil-serialize-all)
174179
@inline(__always)
175-
public mutating func removeFirst() {
180+
@discardableResult
181+
public mutating func removeFirst() -> Element {
176182
_debugPrecondition(!isEmpty)
183+
let result = Element(truncatingIfNeeded: _biasedBits) &- 1
177184
_biasedBits = _biasedBits._fullShiftRight(8)
185+
return result
178186
}
179187

180188
@_inlineable // FIXME(sil-serialize-all)
@@ -196,7 +204,9 @@ extension _ValidUTF8Buffer : RangeReplaceableCollection {
196204
for x in self[target.upperBound...] { r.append(x) }
197205
self = r
198206
}
207+
}
199208

209+
extension _ValidUTF8Buffer {
200210
@_inlineable // FIXME(sil-serialize-all)
201211
@inline(__always)
202212
public mutating func append<T>(contentsOf other: _ValidUTF8Buffer<T>) {

0 commit comments

Comments
 (0)