[Draft] Eliminate unused loop iteration variables

When creating arrays of colors, the color information is often created
to be the same length as some array of objects. In three instances this
was achieved with a loop over that list of objects, even though the
objects themselves are never used. This commit eliminates those loops
and creates the required number of color instances directly.

Identified by LGTM.
This commit is contained in:
Chris Hennes
2021-03-01 09:19:20 -06:00
parent 3e48fef002
commit 784ee36121
2 changed files with 3 additions and 7 deletions

View File

@@ -60,8 +60,7 @@ class ViewProviderDraftArray(ViewProviderDraft):
else:
c = vobj.Object.Base.ViewObject.ShapeColor
c = (c[0],c[1],c[2],vobj.Object.Base.ViewObject.Transparency/100.0)
for f in vobj.Object.Base.Shape.Faces:
colors.append(c)
colors += [c] * len(vobj.Object.Base.Shape.Faces)
if colors:
n = 1
if hasattr(vobj.Object,"ArrayType"):

View File

@@ -61,9 +61,7 @@ class ViewProviderClone:
else:
c = o.ViewObject.ShapeColor
c = (c[0],c[1],c[2],o.ViewObject.Transparency/100.0)
for f in o.Shape.Faces: # TODO: verify this line
colors.append(c)
colors += [c] * len(o.Shape.Faces) # TODO: verify this line
elif o.hasExtension("App::GeoFeatureGroupExtension"):
for so in vobj.Object.Group:
if so.isDerivedFrom("Part::Feature"):
@@ -72,8 +70,7 @@ class ViewProviderClone:
else:
c = so.ViewObject.ShapeColor
c = (c[0],c[1],c[2],so.ViewObject.Transparency/100.0)
for f in so.Shape.Faces:
colors.append(c)
colors += [c] * len(so.Shape.Faces)
if colors:
vobj.DiffuseColor = colors