Skip to content

Commit

Permalink
refactor: use fast return if len(request) < 20
Browse files Browse the repository at this point in the history
  • Loading branch information
IATkachenko committed Jul 8, 2022
1 parent aa6a012 commit 4282e4e
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions tion_btle/light_family.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,16 +107,16 @@ def chunks(lst, n):

if len(request) < 20:
request[0] = self.SINGLE_PACKET_ID
result = [request]
else:
request[0] = self.FIRST_PACKET_ID
result = list(chunks(request, 20))

for i in range(1, len(result)):
if i == len(result)-1:
result[i].insert(0, self.END_PACKET_ID)
else:
result[i].insert(0, self.MIDDLE_PACKET_ID)
return [request]

request[0] = self.FIRST_PACKET_ID
result = list(chunks(request, 20))

for i in range(1, len(result)):
if i == len(result)-1:
result[i].insert(0, self.END_PACKET_ID)
else:
result[i].insert(0, self.MIDDLE_PACKET_ID)

return result

Expand Down

0 comments on commit 4282e4e

Please sign in to comment.