From 5db779dae91945f9edb68552a2fa04e1484b4ac3 Mon Sep 17 00:00:00 2001 From: Stelian Ionescu Date: Wed, 18 Dec 2019 22:43:58 -0500 Subject: [PATCH] Add compiler macro for INC-POINTER Return the pointer if the offset is 0. --- src/types.lisp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/types.lisp b/src/types.lisp index 6863958..985f8ea 100644 --- a/src/types.lisp +++ b/src/types.lisp @@ -123,6 +123,12 @@ ;;;# Foreign Pointers +(define-compiler-macro inc-pointer (&whole form pointer offset) + (if (and (constantp offset) + (eql 0 (eval offset))) + pointer + form)) + (define-modify-macro incf-pointer (&optional (offset 1)) inc-pointer) (defun mem-ref (ptr type &optional (offset 0)) -- 2.11.4.GIT