Skip to content
Permalink
Browse files

Minor changes to speed up PointstoPaths algorithm

# 1: Replaced time-consuming call on all attributes by a more specific request - responsible for about 90% of running time in my tests.
# 2: Minor speedup by calling items() before the for loop (1s in a large layer).

(cherry picked from commit 6c99cbc)
  • Loading branch information
fuzzysolutions authored and nyalldawson committed Oct 22, 2018
1 parent 9094b83 commit 44c851db1d085035128f01a33a7524c7dcfe2b00
Showing with 4 additions and 3 deletions.
  1. +4 −3 python/plugins/processing/algs/qgis/PointsToPaths.py
@@ -144,10 +144,10 @@ def processAlgorithm(self, parameters, context, feedback):

point = f.geometry().constGet().clone()
if group_field_index >= 0:
group = f.attributes()[group_field_index]
group = f[group_field_index] # (1)
else:
group = 1
order = f.attributes()[order_field_index]
order = f[order_field_index] # (1)
if date_format != '':
order = datetime.strptime(str(order), date_format)
if group in points:
@@ -165,7 +165,8 @@ def processAlgorithm(self, parameters, context, feedback):

current = 0
total = 100.0 / len(points) if points else 1
for group, vertices in list(points.items()):
verlist = list(points.items()) # (2)
for group, vertices in vertlist: # (2)
if feedback.isCanceled():
break

0 comments on commit 44c851d

Please sign in to comment.
You can’t perform that action at this time.