Skip to content

Commit f1055a1

Browse files
ES-Alexanderpatrickelectric
authored andcommitted
pingmessage: [performance] replace manual sum with builtin
1 parent 0aa9470 commit f1055a1

1 file changed

Lines changed: 1 addition & 4 deletions

File tree

brping/pingmessage.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -193,10 +193,7 @@ def unpack_msg_data(self, msg_data):
193193

194194
## Calculate the checksum from the internal bytearray self.msg_data
195195
def calculate_checksum(self):
196-
checksum = 0
197-
for byte in self.msg_data[0:PingMessage.headerLength + self.payload_length]:
198-
checksum += byte
199-
return checksum & 0xffff
196+
return sum(self.msg_data[0:PingMessage.headerLength + self.payload_length]) & 0xffff
200197

201198
## Update the object checksum value
202199
# @return the object checksum value

0 commit comments

Comments
 (0)