Navigation Menu

Skip to content

Commit

Permalink
Minor changes to speed up PointstoPaths algorithm
Browse files Browse the repository at this point in the history
# 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 30, 2018
1 parent 9094b83 commit 44c851d
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions python/plugins/processing/algs/qgis/PointsToPaths.py
Expand Up @@ -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:
Expand All @@ -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

Expand Down

0 comments on commit 44c851d

Please sign in to comment.