Skip to content

Commit

Permalink
Performance optimization
Browse files Browse the repository at this point in the history
Don't bother with the regex unless the first 4 characters are OCTO. ~7x faster
  • Loading branch information
kantlivelong committed Apr 24, 2020
1 parent 0cdef74 commit 3a0cfd5
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions octoprint_gcodesystemcommands/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@ def hook_gcode_sending(self, comm_instance, phase, cmd, cmd_type, gcode, *args,
if gcode:
return

if cmd[:4] != 'OCTO':
return

match = re.search(r'^(OCTO[0-9]+)(?:\s(.*))?$', cmd)
if match is None:
return
Expand Down

0 comments on commit 3a0cfd5

Please sign in to comment.