Merge pull request #464 from exarkun/faster-cffi-usage
Make just one call to ffi.cdef for most of the definitions
diff --git a/cryptography/hazmat/bindings/utils.py b/cryptography/hazmat/bindings/utils.py
index 69290eb..9cc0550 100644
--- a/cryptography/hazmat/bindings/utils.py
+++ b/cryptography/hazmat/bindings/utils.py
@@ -34,6 +34,7 @@
condition.
"""
ffi = cffi.FFI()
+ types = []
includes = []
functions = []
macros = []
@@ -43,8 +44,7 @@
__import__(module_name)
module = sys.modules[module_name]
- ffi.cdef(module.TYPES)
-
+ types.append(module.TYPES)
macros.append(module.MACROS)
functions.append(module.FUNCTIONS)
includes.append(module.INCLUDES)
@@ -53,10 +53,7 @@
# loop over the functions & macros after declaring all the types
# so we can set interdependent types in different files and still
# have them all defined before we parse the funcs & macros
- for func in functions:
- ffi.cdef(func)
- for macro in macros:
- ffi.cdef(macro)
+ ffi.cdef("\n".join(types + functions + macros))
# We include functions here so that if we got any of their definitions
# wrong, the underlying C compiler will explode. In C you are allowed