[Mesa-dev] [PATCH 27/41] glapi: gl_XML.py: store compiled re as a module variable

Dylan Baker baker.dylan.c at gmail.com
Fri Apr 1 00:04:44 UTC 2016


This avoids recompiles of the re each time the function is called.

Signed-off-by: Dylan Baker <dylanx.c.baker at intel.com>
---
 src/mapi/glapi/gen/gl_XML.py | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/src/mapi/glapi/gen/gl_XML.py b/src/mapi/glapi/gen/gl_XML.py
index a860b0d..73baef6 100644
--- a/src/mapi/glapi/gen/gl_XML.py
+++ b/src/mapi/glapi/gen/gl_XML.py
@@ -38,6 +38,8 @@ import xml.etree.ElementTree as ET
 import static_data
 import typeexpr
 
+_REAL_CATEGORY_FINDER = re.compile("[1-9][0-9]*[.][0-9]+")
+
 
 def parse_GL_API(file_name, factory=None):
 
@@ -252,7 +254,7 @@ def real_function_name(element):
 
 
 def real_category_name(c):
-    if re.compile("[1-9][0-9]*[.][0-9]+").match(c):
+    if _REAL_CATEGORY_FINDER.match(c):
         return "GL_VERSION_" + c.replace(".", "_")
     else:
         return c
-- 
2.8.0



More information about the mesa-dev mailing list