@@ -335,16 +335,22 @@ impl Delimiters {
335
335
}
336
336
337
337
#[ inline]
338
- fn from_byte ( byte : Option < u8 > ) -> Delimiters {
338
+ pub ( crate ) fn from_byte ( byte : Option < u8 > ) -> Delimiters {
339
+ const TABLE : [ Delimiters ; 256 ] = {
340
+ let mut table = [ Delimiter :: None ; 256 ] ;
341
+ table[ b';' as usize ] = Delimiter :: Semicolon ;
342
+ table[ b'!' as usize ] = Delimiter :: Bang ;
343
+ table[ b',' as usize ] = Delimiter :: Comma ;
344
+ table[ b'{' as usize ] = Delimiter :: CurlyBracketBlock ;
345
+ table[ b'}' as usize ] = ClosingDelimiter :: CloseCurlyBracket ;
346
+ table[ b']' as usize ] = ClosingDelimiter :: CloseSquareBracket ;
347
+ table[ b')' as usize ] = ClosingDelimiter :: CloseParenthesis ;
348
+ table
349
+ } ;
350
+
339
351
match byte {
340
- Some ( b';' ) => Delimiter :: Semicolon ,
341
- Some ( b'!' ) => Delimiter :: Bang ,
342
- Some ( b',' ) => Delimiter :: Comma ,
343
- Some ( b'{' ) => Delimiter :: CurlyBracketBlock ,
344
- Some ( b'}' ) => ClosingDelimiter :: CloseCurlyBracket ,
345
- Some ( b']' ) => ClosingDelimiter :: CloseSquareBracket ,
346
- Some ( b')' ) => ClosingDelimiter :: CloseParenthesis ,
347
- _ => Delimiter :: None ,
352
+ None => Delimiter :: None ,
353
+ Some ( b) => TABLE [ b as usize ] ,
348
354
}
349
355
}
350
356
}
0 commit comments