From 53942bb0de256163e32253c25314163314bd4f62 Mon Sep 17 00:00:00 2001 From: Stas Boukarev Date: Fri, 5 Jun 2015 03:53:30 +0300 Subject: [PATCH] Provide a better type for FORMAT NIL. It will always return (simple-array character (*)). --- src/code/early-extensions.lisp | 3 ++- src/compiler/srctran.lisp | 6 ++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/code/early-extensions.lisp b/src/code/early-extensions.lisp index 1f659bb73..b8f96518a 100644 --- a/src/code/early-extensions.lisp +++ b/src/code/early-extensions.lisp @@ -1707,4 +1707,5 @@ lines and columns." `(let ((,var (make-string-output-stream))) ,@decls ,@forms - (get-output-stream-string ,var))))) + (truly-the (simple-array character (*)) + (get-output-stream-string ,var)))))) diff --git a/src/compiler/srctran.lisp b/src/compiler/srctran.lisp index 405384919..bb7b1f70a 100644 --- a/src/compiler/srctran.lisp +++ b/src/compiler/srctran.lisp @@ -4572,6 +4572,12 @@ (when (stringp x) (check-format-args x args 'format))))) +(defoptimizer (format derive-type) ((dest control &rest args)) + (declare (ignore control args)) + (when (and (constant-lvar-p dest) + (null (lvar-value dest))) + (specifier-type '(simple-array character (*))))) + ;;; We disable this transform in the cross-compiler to save memory in ;;; the target image; most of the uses of FORMAT in the compiler are for ;;; error messages, and those don't need to be particularly fast. -- 2.11.4.GIT