Skip to content

Commit 6c99cbc

Browse files
fuzzysolutionsnyalldawson
authored andcommitted
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).
1 parent 3a18ba6 commit 6c99cbc

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

python/plugins/processing/algs/qgis/PointsToPaths.py

+4-3
Original file line numberDiff line numberDiff line change
@@ -144,10 +144,10 @@ def processAlgorithm(self, parameters, context, feedback):
144144

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

166166
current = 0
167167
total = 100.0 / len(points) if points else 1
168-
for group, vertices in list(points.items()):
168+
verlist = list(points.items()) # (2)
169+
for group, vertices in vertlist: # (2)
169170
if feedback.isCanceled():
170171
break
171172

0 commit comments

Comments
 (0)