Skip to content

Commit f6b3795

Browse files
committed
process rotate uses a comprehension instead of a loop
1 parent e27cd02 commit f6b3795

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

kaitaistruct.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -361,8 +361,8 @@ def process_rotate_left(data, amount, group_size):
361361
if amount == 0:
362362
return data
363363

364-
r = bytearray(data)
365364
translate = KaitaiStream.precomputed_rotations[amount]
366-
for i in range(len(r)):
367-
r[i] = translate[r[i]]
368-
return bytes(r)
365+
if PY2:
366+
return bytes(bytearray(translate[a] for a in bytearray(data)))
367+
else:
368+
return bytes(translate[a] for a in data)

0 commit comments

Comments
 (0)