Replace 4 .append calls with a single one when serializing bytes

This commit is contained in:
Lonami Exo 2017-09-26 14:41:11 +02:00
parent b83cd98ba0
commit 98c2e1dd4f

View File

@ -101,10 +101,12 @@ class TLObject:
if padding != 0:
padding = 4 - padding
r.append(bytes([254]))
r.append(bytes([len(data) % 256]))
r.append(bytes([(len(data) >> 8) % 256]))
r.append(bytes([(len(data) >> 16) % 256]))
r.append(bytes([
254,
len(data) % 256,
(len(data) >> 8) % 256,
(len(data) >> 16) % 256
]))
r.append(data)
r.append(bytes(padding))