[PATCH] Fold (foreign-type-size <built-in-type>) to constants
Max Mikhanosha
max at openchat.com
Fri May 24 02:00:30 UTC 2013
Hi,
PZMQ uses (foreign-type-size) dynamically on built-in types in its
getsockopt functions, which is called on every recv-string message call.
Please apply the following short patch, it seems self-obviously correct.
Regards,
Max
From c3f6ede805431eac6d96379691ab54a0a951d4f3 Mon Sep 17 00:00:00 2001
From: Max Mikhanosha <max at openchat.com>
Date: Thu, 23 May 2013 21:50:58 -0400
Subject: [PATCH] Fold (foreign-type-size <built-in-type>) to constants
---
src/types.lisp | 9 +++++++++
1 file changed, 9 insertions(+)
diff --git a/src/types.lisp b/src/types.lisp
index 582a94d..ea5a020 100644
--- a/src/types.lisp
+++ b/src/types.lisp
@@ -1009,3 +1009,12 @@ (defctype :ullong :unsigned-long-long)
(:uintptr . :pointer))
(:unsigned-char :unsigned-short :unsigned-int :unsigned-long
:unsigned-long-long))))
+
+;; Fold foreign-type-size on built-in types to constants
+(define-compiler-macro foreign-type-size (&whole form type)
+ (if (constantp type)
+ (let ((type (eval type)))
+ (if (member type *built-in-foreign-types*)
+ (%foreign-type-size type)
+ form))
+ form))
--
1.7.11.rc0.100.g5498c5f
More information about the cffi-devel
mailing list