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 {
2929 self . base = . none( reserveCapacity: 0 )
3030 case 1 :
3131 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+ )
3238 default :
3339 if let collection = collection as? Array < Element > {
3440 self . base = . n( collection)
@@ -46,7 +52,7 @@ struct TinyFastSequence<Element>: Sequence {
4652 case 1 :
4753 self . base = . one( max2Sequence. first!, reserveCapacity: 0 )
4854 case 2 :
49- self . base = . n ( Array ( max2Sequence) )
55+ self . base = . two ( max2Sequence. first! , max2Sequence . second! , reserveCapacity : 0 )
5056 default :
5157 fatalError ( )
5258 }
@@ -169,7 +175,7 @@ struct TinyFastSequence<Element>: Sequence {
169175
170176 case . n( let array) :
171177 if self . index < array. endIndex {
172- defer { self . index += 1 }
178+ defer { self . index += 1 }
173179 return array [ self . index]
174180 }
175181 return nil
Original file line number Diff line number Diff line change @@ -46,11 +46,19 @@ final class TinyFastSequenceTests: XCTestCase {
4646 XCTAssertEqual ( array. capacity, 8 )
4747
4848 var twoElemSequence = TinyFastSequence < Int > ( [ 1 , 2 ] )
49+ twoElemSequence. append ( 3 )
4950 twoElemSequence. reserveCapacity ( 8 )
5051 guard case . n( let array) = twoElemSequence. base else {
5152 return XCTFail ( " Expected sequence to be backed by an array " )
5253 }
5354 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 )
5462 }
5563
5664 func testNewSequenceSlowPath( ) {
You can’t perform that action at this time.
0 commit comments