PSSH: Optimize how overwrite_key_ids works with the repeated field
We can clear a repeated field with `del field[:]` and overwrite an entire field with `field[:] = [b"123", b"456"]`. So we can reduce this down to a single call operation.
This commit is contained in:
parent
10fb954097
commit
76c7a402eb
|
@ -270,13 +270,10 @@ class PSSH:
|
|||
init = WidevinePsshData()
|
||||
init.ParseFromString(box.init_data)
|
||||
|
||||
# TODO: Is there a better way to clear the Key IDs?
|
||||
for _ in range(len(init.key_ids or [])):
|
||||
init.key_ids.pop(0)
|
||||
|
||||
# TODO: Is there a .extend or a way to add all without a loop?
|
||||
for key_id in key_ids:
|
||||
init.key_ids.append(key_id.bytes)
|
||||
init.key_ids[:] = [
|
||||
key_id.bytes
|
||||
for key_id in key_ids
|
||||
]
|
||||
|
||||
box.init_data = init.SerializeToString()
|
||||
|
||||
|
|
Loading…
Reference in New Issue