Skip to content

Commit 7c85954

Browse files
Code review suggestions
1 parent ac0614a commit 7c85954

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

lib/matplotlib/collections.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1244,13 +1244,12 @@ def set_verts(self, verts, closed=True):
12441244
# Fast path for arrays
12451245
if isinstance(verts, np.ndarray) and len(verts.shape) == 3 and verts.size:
12461246
verts_pad = np.concatenate((verts, verts[:, :1]), axis=1)
1247-
# Creating the codes once is much faster than having Path do it
1248-
# separately each time by passing closed=True.
1249-
example_path = mpath.Path(verts_pad[0], closed=True)
1250-
# Looking up the values once speeds up the iteration a bit
1247+
# It's faster to create the codes and internal flags once in a
1248+
# template path and reuse them.
1249+
template_path = mpath.Path(verts_pad[0], closed=True)
1250+
codes = template_path.codes
12511251
_make_path = mpath.Path._fast_from_codes_and_verts
1252-
codes = example_path.codes
1253-
self._paths = [_make_path(xy, codes, internals_from=example_path)
1252+
self._paths = [_make_path(xy, codes, internals_from=template_path)
12541253
for xy in verts_pad]
12551254
return
12561255

0 commit comments

Comments
 (0)