File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -15,8 +15,11 @@ cdef cython.uint _FLAGS_TC
1515cdef cython.uint _MAX_MSG_ABSOLUTE
1616cdef cython.uint _MAX_MSG_TYPICAL
1717
18+
1819cdef bint TYPE_CHECKING
1920
21+ cdef unsigned int SHORT_CACHE_MAX
22+
2023cdef object PACK_BYTE
2124cdef object PACK_SHORT
2225cdef object PACK_LONG
Original file line number Diff line number Diff line change 5353PACK_SHORT = Struct ('>H' ).pack
5454PACK_LONG = Struct ('>L' ).pack
5555
56+ SHORT_CACHE_MAX = 128
57+
5658BYTE_TABLE = tuple (PACK_BYTE (i ) for i in range (256 ))
57- SHORT_LOOKUP = tuple (PACK_SHORT (i ) for i in range (32 ))
59+ SHORT_LOOKUP = tuple (PACK_SHORT (i ) for i in range (SHORT_CACHE_MAX ))
5860
5961
6062class State (enum .Enum ):
@@ -223,7 +225,7 @@ def _write_byte(self, value: int_) -> None:
223225
224226 def _get_short (self , value : int_ ) -> bytes :
225227 """Gets an unsigned short from a certain position in the packet"""
226- if value < 32 :
228+ if value < SHORT_CACHE_MAX :
227229 return SHORT_LOOKUP [value ]
228230 return PACK_SHORT (value )
229231
You can’t perform that action at this time.
0 commit comments