From 12ea292993da7598af811498f74493cde38ebd53 Mon Sep 17 00:00:00 2001
From: Andrew Maclean <andrew.amaclean@gmail.com>
Date: Sat, 25 Sep 2021 16:39:55 +1000
Subject: [PATCH] Move regexp compiles out of the loop

---
 src/Python/Utilities/VTKImportsForPython.py | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/src/Python/Utilities/VTKImportsForPython.py b/src/Python/Utilities/VTKImportsForPython.py
index bf0d02251c9..2112b84fd5c 100755
--- a/src/Python/Utilities/VTKImportsForPython.py
+++ b/src/Python/Utilities/VTKImportsForPython.py
@@ -53,13 +53,15 @@ def get_classes_constants(paths):
     :param paths: The path(s) to the Python file(s).
     :return: The file name, the VTK classes and any VTK constants.
     """
+    
+    vtk_class_pattern = re.compile(r'(vtk[a-zA-Z]+\S+\()')
+    vtk_class_pattern1 = re.compile(r'[^\(]+')
+    vtk_constants_pattern = re.compile(r'(VTK_[A-Z_]+)')
+
     res = collections.defaultdict(set)
     for path in paths:
         content = path.read_text().split('\n')
         for line in content:
-            vtk_class_pattern = re.compile(r'(vtk[a-zA-Z]+\S+\()')
-            vtk_class_pattern1 = re.compile(r'[^\(]+')
-            vtk_constants_pattern = re.compile(r'(VTK_[A-Z_]+)')
             m = vtk_class_pattern.search(line)
             if m:
                 for g in m.groups():
-- 
GitLab