Skip to content

Commit 428cbf5

Browse files
authored
Read integers first when size matches
1 parent 362441a commit 428cbf5

File tree

1 file changed

+7
-9
lines changed

1 file changed

+7
-9
lines changed

pyrogram/raw/core/primitives/vector.py

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -31,21 +31,19 @@ class Vector(bytes, TLObject):
3131
# i.e., RpcResult body starts with 0x1cb5c415 (Vector Id) - e.g., messages.GetMessagesViews.
3232
@staticmethod
3333
def read_bare(b: BytesIO, size: int) -> Union[int, Any]:
34-
try:
35-
return TLObject.read(b)
36-
except KeyError:
37-
b.seek(-4, 1)
34+
if size == 4:
35+
return Int.read(b)
36+
37+
if size == 8:
38+
return Long.read(b)
3839

39-
if size == 4:
40-
return Int.read(b)
41-
else:
42-
return Long.read(b)
40+
return TLObject.read(b)
4341

4442
@classmethod
4543
def read(cls, data: BytesIO, t: Any = None, *args: Any) -> List:
4644
count = Int.read(data)
4745
left = len(data.read())
48-
size = (left // count) if count else 0
46+
size = (left / count) if count else 0
4947
data.seek(-left, 1)
5048

5149
return List(

0 commit comments

Comments
 (0)