File tree Expand file tree Collapse file tree 2 files changed +16
-2
lines changed
Sources/ConnectionPoolModule
Tests/ConnectionPoolModuleTests Expand file tree Collapse file tree 2 files changed +16
-2
lines changed Original file line number Diff line number Diff line change @@ -29,6 +29,12 @@ struct TinyFastSequence<Element>: Sequence {
29
29
self . base = . none( reserveCapacity: 0 )
30
30
case 1 :
31
31
self . base = . one( collection. first!, reserveCapacity: 0 )
32
+ case 2 :
33
+ self . base = . two(
34
+ collection. first!,
35
+ collection [ collection. index ( after: collection. startIndex) ] ,
36
+ reserveCapacity: 0
37
+ )
32
38
default :
33
39
if let collection = collection as? Array < Element > {
34
40
self . base = . n( collection)
@@ -46,7 +52,7 @@ struct TinyFastSequence<Element>: Sequence {
46
52
case 1 :
47
53
self . base = . one( max2Sequence. first!, reserveCapacity: 0 )
48
54
case 2 :
49
- self . base = . n ( Array ( max2Sequence) )
55
+ self . base = . two ( max2Sequence. first! , max2Sequence . second! , reserveCapacity : 0 )
50
56
default :
51
57
fatalError ( )
52
58
}
@@ -169,7 +175,7 @@ struct TinyFastSequence<Element>: Sequence {
169
175
170
176
case . n( let array) :
171
177
if self . index < array. endIndex {
172
- defer { self . index += 1 }
178
+ defer { self . index += 1 }
173
179
return array [ self . index]
174
180
}
175
181
return nil
Original file line number Diff line number Diff line change @@ -46,11 +46,19 @@ final class TinyFastSequenceTests: XCTestCase {
46
46
XCTAssertEqual ( array. capacity, 8 )
47
47
48
48
var twoElemSequence = TinyFastSequence < Int > ( [ 1 , 2 ] )
49
+ twoElemSequence. append ( 3 )
49
50
twoElemSequence. reserveCapacity ( 8 )
50
51
guard case . n( let array) = twoElemSequence. base else {
51
52
return XCTFail ( " Expected sequence to be backed by an array " )
52
53
}
53
54
XCTAssertEqual ( array. capacity, 8 )
55
+
56
+ var threeElemSequence = TinyFastSequence < Int > ( [ 1 , 2 , 3 ] )
57
+ threeElemSequence. reserveCapacity ( 8 )
58
+ guard case . n( let array) = threeElemSequence. base else {
59
+ return XCTFail ( " Expected sequence to be backed by an array " )
60
+ }
61
+ XCTAssertEqual ( array. capacity, 8 )
54
62
}
55
63
56
64
func testNewSequenceSlowPath( ) {
You can’t perform that action at this time.
0 commit comments