=== modified file 'src/alloc.c' --- src/alloc.c 2012-06-26 14:41:01 +0000 +++ src/alloc.c 2012-06-26 17:26:02 +0000 @@ -2533,6 +2533,25 @@ return string; } +/* Fast version used when both STR and NBYTES are compile-time + constants, and all characters from STR are ASCII. */ + +Lisp_Object +build_literal (const char *str, ptrdiff_t nbytes) +{ + Lisp_Object string; + struct Lisp_String *s; + + eassert (nbytes > 0); + + s = allocate_string (); + allocate_string_data (s, nbytes, nbytes); + memcpy (s->data, str, nbytes); + string_chars_consed += nbytes; + + XSETSTRING (string, s); + return string; +} /*********************************************************************** === modified file 'src/lisp.h' --- src/lisp.h 2012-06-26 05:00:30 +0000 +++ src/lisp.h 2012-06-26 17:24:48 +0000 @@ -2716,12 +2716,28 @@ /* Make a string from the data at STR, treating it as multibyte if the data warrants. */ +#ifdef __GNUC__ + +extern Lisp_Object build_literal (const char *str, ptrdiff_t nbytes); + +#define build_string(str) \ + ({ Lisp_Object __val; \ + if (__builtin_constant_p (str) && strlen (str) > 0) \ + __val = build_literal (str, strlen (str)); \ + else \ + __val = make_string (str, strlen (str)); \ + __val; }) + +#else + static inline Lisp_Object build_string (const char *str) { return make_string (str, strlen (str)); } +#endif + extern Lisp_Object pure_cons (Lisp_Object, Lisp_Object); EXFUN (Fgarbage_collect, 0); extern void make_byte_code (struct Lisp_Vector *);