11from utils import StringSlice
22from memory.span import Span, _SpanIter
3+ from lightbug_http.strings import BytesConstant
34from lightbug_http.net import default_buffer_size
45
56
67alias Bytes = List[Byte, True ]
78
89
9- struct Constant :
10- alias WHITESPACE : UInt8 = ord (" " )
11- alias CR : UInt8 = ord (" \r " )
12- alias LF : UInt8 = ord (" \n " )
13-
14-
1510@always_inline
1611fn byte (s : String) -> Byte:
1712 return ord (s)
@@ -24,12 +19,12 @@ fn bytes(s: String) -> Bytes:
2419
2520@always_inline
2621fn is_newline (b : Byte) -> Bool:
27- return b == Constant. LF or b == Constant. CR
22+ return b == BytesConstant.nChar or b == BytesConstant.rChar
2823
2924
3025@always_inline
3126fn is_space (b : Byte) -> Bool:
32- return b == Constant. WHITESPACE
27+ return b == BytesConstant.whitespace
3328
3429
3530struct ByteWriter (Writer ):
@@ -223,7 +218,7 @@ struct ByteReader[origin: Origin]:
223218
224219 @always_inline
225220 fn read_word (mut self ) -> ByteView[origin]:
226- return self .read_until(Constant. WHITESPACE )
221+ return self .read_until(BytesConstant.whitespace )
227222
228223 fn read_line (mut self ) -> ByteView[origin]:
229224 var start = self .read_pos
@@ -237,7 +232,7 @@ struct ByteReader[origin: Origin]:
237232 if not self .available():
238233 return ret
239234
240- if self ._inner[self .read_pos] == Constant. CR :
235+ if self ._inner[self .read_pos] == BytesConstant.rChar :
241236 self .increment(2 )
242237 else :
243238 self .increment()
@@ -254,7 +249,7 @@ struct ByteReader[origin: Origin]:
254249 @always_inline
255250 fn skip_carriage_return (mut self ):
256251 for i in range (self .read_pos, len (self ._inner)):
257- if self ._inner[i] == Constant. CR :
252+ if self ._inner[i] == BytesConstant.rChar :
258253 self .increment(2 )
259254 else :
260255 break
0 commit comments