From 0872e11f1595845e7f3ba2c0d8e53ec7fc0f49e3 Mon Sep 17 00:00:00 2001 From: "Richard M. Stallman" Date: Fri, 20 Jun 1997 08:45:37 +0000 Subject: [PATCH] (Ferror_message_string): Optimize (error STRING) case. --- src/print.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/print.c b/src/print.c index 933544467ca..6ac2b25745d 100644 --- a/src/print.c +++ b/src/print.c @@ -727,6 +727,15 @@ DEFUN ("error-message-string", Ferror_message_string, Serror_message_string, Lisp_Object original, printcharfun, value; struct gcpro gcpro1; + /* If OBJ is (error STRING), just return STRING. + That is not only faster, it also avoids the need to allocate + space here when the error is due to memory full. */ + if (CONSP (obj) && EQ (XCONS (obj)->car, Qerror) + && CONSP (XCONS (obj)->cdr) + && STRINGP (XCONS (XCONS (obj)->cdr)->car) + && NILP (XCONS (XCONS (obj)->cdr)->cdr)) + return XCONS (XCONS (obj)->cdr)->car; + print_error_message (obj, Vprin1_to_string_buffer, NULL); set_buffer_internal (XBUFFER (Vprin1_to_string_buffer)); -- 2.39.2