Track index instead of finding it back later

It has to iterate over all layers and do string comparison to find the index back. Instead we just keep track of the index so this should improve performance a bit.
This commit is contained in:
Ghostkeeper 2018-02-12 11:12:55 +01:00
parent 80b99e0323
commit b8fce75dac
No known key found for this signature in database
GPG key ID: 5252B696FB5E7C7A

View file

@ -121,7 +121,7 @@ class PauseAtHeight(Script):
# use offset to calculate the current height: <current_height> = <current_z> - <layer_0_z>
layer_0_z = 0.
got_first_g_cmd_on_layer_0 = False
for layer in data:
for index, layer in enumerate(data):
lines = layer.split("\n")
for line in lines:
if ";LAYER:0" in line:
@ -146,7 +146,6 @@ class PauseAtHeight(Script):
if current_height < pause_height:
break #Try the next layer.
index = data.index(layer)
prevLayer = data[index - 1]
prevLines = prevLayer.split("\n")
current_e = 0.