mirror of
https://github.com/LonamiWebs/Telethon.git
synced 2025-08-08 04:52:30 +00:00
Precompute the flag index on the generated code
This commit is contained in:
@@ -472,8 +472,8 @@ class TLGenerator:
|
||||
elif arg.flag_indicator:
|
||||
# Calculate the flags with those items which are not None
|
||||
builder.write("struct.pack('<I', {})".format(
|
||||
' | '.join('(1 << {} if {} else 0)'.format(
|
||||
flag.flag_index, 'self.{}'.format(flag.name)
|
||||
' | '.join('({} if {} else 0)'.format(
|
||||
1 << flag.flag_index, 'self.{}'.format(flag.name)
|
||||
) for flag in args if flag.is_flag)
|
||||
))
|
||||
|
||||
@@ -550,8 +550,8 @@ class TLGenerator:
|
||||
was_flag = False
|
||||
if arg.is_flag:
|
||||
was_flag = True
|
||||
builder.writeln('if (flags & (1 << {})) != 0:'.format(
|
||||
arg.flag_index
|
||||
builder.writeln('if flags & {}:'.format(
|
||||
1 << arg.flag_index
|
||||
))
|
||||
# Temporary disable .is_flag not to enter this if
|
||||
# again when calling the method recursively
|
||||
|
Reference in New Issue
Block a user