File tree Expand file tree Collapse file tree 1 file changed +12
-11
lines changed Expand file tree Collapse file tree 1 file changed +12
-11
lines changed Original file line number Diff line number Diff line change 2121import  struct 
2222from  enum  import  IntEnum 
2323from  io  import  BytesIO 
24+ from  typing  import  List 
2425
2526from  pyrogram .raw .core  import  Bytes , String 
2627
@@ -63,36 +64,36 @@ def rle_encode(s: bytes) -> bytes:
6364 Returns: 
6465 ``bytes``: The encoded bytes 
6566 """ 
66-  r : bytes  =  b"" 
67+  r : List [ int ]  =  [] 
6768 n : int  =  0 
6869
6970 for  b  in  s :
7071 if  not  b :
7172 n  +=  1 
7273 else :
7374 if  n :
74-  r   +=   bytes ([ 0 , n ] )
75+  r . extend (( 0 , n ) )
7576 n  =  0 
7677
77-  r   +=   bytes ([ b ] )
78+  r . append ( b )
7879
7980 if  n :
80-  r   +=   bytes ([ 0 , n ] )
81+  r . extend (( 0 , n ) )
8182
82-  return  r 
83+  return  bytes ( r ) 
8384
8485
8586def  rle_decode (s : bytes ) ->  bytes :
8687 """Zero-value RLE decoder 
8788
8889 Parameters: 
8990 s (``bytes``): 
90-  Bytes to encode  
91+  Bytes to decode  
9192
9293 Returns: 
93-  ``bytes``: The encoded  bytes 
94+  ``bytes``: The decoded  bytes 
9495 """ 
95-  r : bytes  =  b"" 
96+  r : List [ int ]  =  [] 
9697 z : bool  =  False 
9798
9899 for  b  in  s :
@@ -101,12 +102,12 @@ def rle_decode(s: bytes) -> bytes:
101102 continue 
102103
103104 if  z :
104-  r   +=   b" \x00 "   *  b 
105+  r . extend (( 0 ,)  *  b ) 
105106 z  =  False 
106107 else :
107-  r   +=   bytes ([ b ] )
108+  r . append ( b )
108109
109-  return  r 
110+  return  bytes ( r ) 
110111
111112
112113class  FileType (IntEnum ):
                                 You can’t perform that action at this time. 
               
                  
0 commit comments