Microoptimization to not build the same string twice

master
Bryan Mayland 2013-06-28 13:55:42 -04:00
parent cb30d1fdd0
commit b9144c2edc
1 changed files with 3 additions and 2 deletions

View File

@ -989,8 +989,9 @@ class MachineCom(object):
def _doSendWithChecksum(self, cmd, lineNumber):
self._logger.debug("Sending cmd '%s' with lineNumber %r" % (cmd, lineNumber))
checksum = reduce(lambda x,y:x^y, map(ord, "N%d %s" % (lineNumber, cmd)))
commandToSend = "N%d %s*%d" % (lineNumber, cmd, checksum)
commandToSend = "N%d %s" % (lineNumber, cmd)
checksum = reduce(lambda x,y:x^y, map(ord, commandToSend))
commandToSend = "%s*%d" % (commandToSend, checksum)
self._doSendWithoutChecksum(commandToSend)
def _doSendWithoutChecksum(self, cmd):