@@ -132,15 +132,27 @@ open class RESPChannelHandler : ChannelDuplexHandler {
132
132
ctx. write ( wrapOutboundOut ( out) , promise: promise)
133
133
}
134
134
135
- @inline ( __always)
136
- final func encode< S: ContiguousCollection > ( simpleString bytes: S ,
137
- out: inout ByteBuffer )
138
- where S. Element == UInt8
139
- {
140
- out. write ( integer : UInt8 ( 43 ) ) // +
141
- out. write ( bytes : bytes)
142
- out. write ( bytes : eol)
143
- }
135
+ #if swift(>=5)
136
+ @inline ( __always)
137
+ final func encode< S: Collection > ( simpleString bytes: S ,
138
+ out: inout ByteBuffer )
139
+ where S. Element == UInt8
140
+ {
141
+ out. writeInteger ( UInt8 ( 43 ) ) // +
142
+ out. writeBytes ( bytes)
143
+ out. writeBytes ( eol)
144
+ }
145
+ #else
146
+ @inline ( __always)
147
+ final func encode< S: ContiguousCollection > ( simpleString bytes: S ,
148
+ out: inout ByteBuffer )
149
+ where S. Element == UInt8
150
+ {
151
+ out. writeInteger ( UInt8 ( 43 ) ) // +
152
+ out. writeBytes ( bytes)
153
+ out. writeBytes ( eol)
154
+ }
155
+ #endif
144
156
145
157
@inline ( __always)
146
158
final func encode( simpleString bytes: ByteBuffer , out: inout ByteBuffer ) {
@@ -164,22 +176,41 @@ open class RESPChannelHandler : ChannelDuplexHandler {
164
176
}
165
177
}
166
178
167
- @inline ( __always)
168
- final func encode< S: ContiguousCollection > ( bulkString bytes: S ? ,
169
- out: inout ByteBuffer )
170
- where S. Element == UInt8
171
- {
172
- if let s = bytes {
173
- out. write ( integer : UInt8 ( 36 ) ) // $
174
- out. write ( integerAsString : Int ( s. count) )
175
- out. write ( bytes : eol)
176
- out. write ( bytes : s)
177
- out. write ( bytes : eol)
179
+ #if swift(>=5)
180
+ @inline ( __always)
181
+ final func encode< S: Collection > ( bulkString bytes: S ? ,
182
+ out: inout ByteBuffer )
183
+ where S. Element == UInt8
184
+ {
185
+ if let s = bytes {
186
+ out. writeInteger ( UInt8 ( 36 ) ) // $
187
+ out. write ( integerAsString : Int ( s. count) )
188
+ out. writeBytes ( eol)
189
+ out. writeBytes ( s)
190
+ out. writeBytes ( eol)
191
+ }
192
+ else {
193
+ out. writeBytes ( nilString)
194
+ }
178
195
}
179
- else {
180
- out. write ( bytes: nilString)
196
+ #else
197
+ @inline ( __always)
198
+ final func encode< S: ContiguousCollection > ( bulkString bytes: S ? ,
199
+ out: inout ByteBuffer )
200
+ where S. Element == UInt8
201
+ {
202
+ if let s = bytes {
203
+ out. writeInteger ( UInt8 ( 36 ) ) // $
204
+ out. write ( integerAsString : Int ( s. count) )
205
+ out. writeBytes ( eol)
206
+ out. writeBytes ( s)
207
+ out. writeBytes ( eol)
208
+ }
209
+ else {
210
+ out. writeBytes ( nilString)
211
+ }
181
212
}
182
- }
213
+ #endif
183
214
184
215
@inline ( __always)
185
216
final func encode( integer i: Int , out: inout ByteBuffer ) {
0 commit comments