mirror of https://github.com/django/django.git
Refs #28024 -- Optimized LineString.__init__() by avoiding superfluous index and dimension checks.
This commit is contained in:
parent
ea542a9c72
commit
6d5bb6ae9e
|
@ -73,16 +73,18 @@ class LineString(LinearGeometryMixin, GEOSGeometry):
|
|||
numpy_coords = True
|
||||
|
||||
# Creating a coordinate sequence object because it is easier to
|
||||
# set the points using GEOSCoordSeq.__setitem__().
|
||||
# set the points using its methods.
|
||||
cs = GEOSCoordSeq(capi.create_cs(ncoords, ndim), z=bool(ndim == 3))
|
||||
point_setter = cs._set_point_3d if ndim == 3 else cs._set_point_2d
|
||||
|
||||
for i in range(ncoords):
|
||||
if numpy_coords:
|
||||
cs[i] = coords[i, :]
|
||||
point_coords = coords[i, :]
|
||||
elif isinstance(coords[i], Point):
|
||||
cs[i] = coords[i].tuple
|
||||
point_coords = coords[i].tuple
|
||||
else:
|
||||
cs[i] = coords[i]
|
||||
point_coords = coords[i]
|
||||
point_setter(i, point_coords)
|
||||
|
||||
# Calling the base geometry initialization with the returned pointer
|
||||
# from the function.
|
||||
|
|
Loading…
Reference in New Issue