Skip to content

Commit

Permalink
gcode: Some optimizations to get_raw_command_parameters()
Browse files Browse the repository at this point in the history
Add some minor optimizations to the get_raw_command_parameters() code.

Signed-off-by: Kevin O'Connor <[email protected]>
  • Loading branch information
KevinOConnor committed Dec 1, 2024
1 parent 62325d4 commit a6df541
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions klippy/gcode.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,18 +28,18 @@ def get_command_parameters(self):
return self._params
def get_raw_command_parameters(self):
command = self._command
rawparams = self._commandline
urawparams = rawparams.upper()
if not urawparams.startswith(command):
origline = self._commandline
param_start = len(command)
param_end = len(origline)
if origline[:param_start].upper() != command:
# Skip any gcode line-number and ignore any trailing checksum
rawparams = rawparams[urawparams.find(command):]
end = rawparams.rfind('*')
param_start += origline.upper().find(command)
end = origline.rfind('*')
if end >= 0:
rawparams = rawparams[:end]
rawparams = rawparams[len(command):]
if rawparams.startswith(' '):
rawparams = rawparams[1:]
return rawparams
param_end = end
if origline[param_start:param_start+1].isspace():
param_start += 1
return origline[param_start:param_end]
def ack(self, msg=None):
if not self._need_ack:
return False
Expand Down

0 comments on commit a6df541

Please sign in to comment.