]> code.delx.au - gnu-emacs/commitdiff
Minor adjustments to interning code.
authorDmitry Antipov <dmantipov@yandex.ru>
Wed, 11 Jul 2012 07:37:39 +0000 (11:37 +0400)
committerDmitry Antipov <dmantipov@yandex.ru>
Wed, 11 Jul 2012 07:37:39 +0000 (11:37 +0400)
* lisp.h (intern, intern_c_string): Redefine as static inline
wrappers for intern_1 and intern_c_string_1, respectively.
(intern_1, intern_c_string_1): Rename prototypes.
* lread.c (intern_1, intern_c_string_1): Simplify Vobarray checking.
* font.c (font_intern_prop): Likewise.  Adjust comment.
* w32font.c (intern_font_name): Likewise.

src/ChangeLog
src/font.c
src/lisp.h
src/lread.c
src/w32font.c

index 5542d1db0f1fade56b46fa7967066e2f4b6f159e..eb28180b7c36edc94c734c2ff58766c32a967bc5 100644 (file)
@@ -1,3 +1,13 @@
+2012-07-11  Dmitry Antipov  <dmantipov@yandex.ru>
+
+       Minor adjustments to interning code.
+       * lisp.h (intern, intern_c_string): Redefine as static inline
+       wrappers for intern_1 and intern_c_string_1, respectively.
+       (intern_1, intern_c_string_1): Rename prototypes.
+       * lread.c (intern_1, intern_c_string_1): Simplify Vobarray checking.
+       * font.c (font_intern_prop): Likewise.  Adjust comment.
+       * w32font.c (intern_font_name): Likewise.
+
 2012-07-11  Andreas Schwab  <schwab@linux-m68k.org>
 
        * gnutls.c (Fgnutls_boot): Properly parse :keylist argument.
index a57029b4af2ed315fd49f34ea8a5bcca3538c4d4..74f58878391319e1d5aa85d54472c755195d7b76 100644 (file)
@@ -264,18 +264,12 @@ font_intern_prop (const char *str, ptrdiff_t len, int force_symbol)
        }
     }
 
-  /* The following code is copied from the function intern (in
-     lread.c), and modified to suit our purpose.  */
-  obarray = Vobarray;
-  if (!VECTORP (obarray) || ASIZE (obarray) == 0)
-    obarray = check_obarray (obarray);
+  /* This code is similar to intern function from lread.c.  */
+  obarray = check_obarray (Vobarray);
   parse_str_as_multibyte ((unsigned char *) str, len, &nchars, &nbytes);
-  if (len == nchars || len != nbytes)
-    /* CONTENTS contains no multibyte sequences or contains an invalid
-       multibyte sequence.  We'll make a unibyte string.  */
-    tem = oblookup (obarray, str, len, len);
-  else
-    tem = oblookup (obarray, str, nchars, len);
+  tem = oblookup (obarray, str,
+                 (len == nchars || len != nbytes) ? len : nchars, len);
+
   if (SYMBOLP (tem))
     return tem;
   if (len == nchars || len != nbytes)
index 5077713451ef32f895fe70ca2561573804b28e14..e01f21e84d84833cb31d41a29de62f5fd76cb97a 100644 (file)
@@ -2734,8 +2734,8 @@ extern ptrdiff_t evxprintf (char **, ptrdiff_t *, char const *, ptrdiff_t,
 extern Lisp_Object Qvariable_documentation, Qstandard_input;
 extern Lisp_Object Qbackquote, Qcomma, Qcomma_at, Qcomma_dot, Qfunction;
 extern Lisp_Object check_obarray (Lisp_Object);
-extern Lisp_Object intern (const char *);
-extern Lisp_Object intern_c_string (const char *);
+extern Lisp_Object intern_1 (const char *, ptrdiff_t);
+extern Lisp_Object intern_c_string_1 (const char *, ptrdiff_t);
 extern Lisp_Object oblookup (Lisp_Object, const char *, ptrdiff_t, ptrdiff_t);
 #define LOADHIST_ATTACH(x) \
   do {                                                                 \
@@ -2752,6 +2752,18 @@ extern void init_obarray (void);
 extern void init_lread (void);
 extern void syms_of_lread (void);
 
+static inline Lisp_Object
+intern (const char *str)
+{
+  return intern_1 (str, strlen (str));
+}
+
+static inline Lisp_Object
+intern_c_string (const char *str)
+{
+  return intern_c_string_1 (str, strlen (str));
+}
+
 /* Defined in eval.c.  */
 extern Lisp_Object Qautoload, Qexit, Qinteractive, Qcommandp, Qmacro;
 extern Lisp_Object Qinhibit_quit, Qclosure;
index f74d44d12a8b9149d6c6264c36e2e5ed71733618..13f4141319609d19473a5ebb2bc33adeaaf6becc 100644 (file)
@@ -3652,32 +3652,20 @@ check_obarray (Lisp_Object obarray)
    interned in the current obarray.  */
 
 Lisp_Object
-intern (const char *str)
+intern_1 (const char *str, ptrdiff_t len)
 {
-  Lisp_Object tem;
-  ptrdiff_t len = strlen (str);
-  Lisp_Object obarray;
+  Lisp_Object obarray = check_obarray (Vobarray);
+  Lisp_Object tem = oblookup (obarray, str, len, len);
 
-  obarray = Vobarray;
-  if (!VECTORP (obarray) || ASIZE (obarray) == 0)
-    obarray = check_obarray (obarray);
-  tem = oblookup (obarray, str, len, len);
-  if (SYMBOLP (tem))
-    return tem;
-  return Fintern (make_string (str, len), obarray);
+  return SYMBOLP (tem) ? tem : Fintern (make_string (str, len), obarray);
 }
 
 Lisp_Object
-intern_c_string (const char *str)
+intern_c_string_1 (const char *str, ptrdiff_t len)
 {
-  Lisp_Object tem;
-  ptrdiff_t len = strlen (str);
-  Lisp_Object obarray;
+  Lisp_Object obarray = check_obarray (Vobarray);
+  Lisp_Object tem = oblookup (obarray, str, len, len);
 
-  obarray = Vobarray;
-  if (!VECTORP (obarray) || ASIZE (obarray) == 0)
-    obarray = check_obarray (obarray);
-  tem = oblookup (obarray, str, len, len);
   if (SYMBOLP (tem))
     return tem;
 
index d2f8410f1de8b89912aacfa5c8e7a9d236cc1270..0200d7ce074f583b472f835ff0b20690a1aae736 100644 (file)
@@ -289,20 +289,12 @@ memq_no_quit (Lisp_Object elt, Lisp_Object list)
 Lisp_Object
 intern_font_name (char * string)
 {
-  Lisp_Object obarray, tem, str;
-  int len;
-
-  str = DECODE_SYSTEM (build_string (string));
-  len = SCHARS (str);
-
-  /* The following code is copied from the function intern (in lread.c).  */
-  obarray = Vobarray;
-  if (!VECTORP (obarray) || ASIZE (obarray) == 0)
-    obarray = check_obarray (obarray);
-  tem = oblookup (obarray, SDATA (str), len, len);
-  if (SYMBOLP (tem))
-    return tem;
-  return Fintern (str, obarray);
+  Lisp_Object str = DECODE_SYSTEM (build_string (string));
+  int len = SCHARS (str);
+  Lisp_Object obarray = check_obarray (Vobarray);
+  Lisp_Object tem = oblookup (obarray, SDATA (str), len, len);  
+  /* This code is similar to intern function from lread.c.  */
+  return SYMBOLP (tem) ? tem : Fintern (str, obarray);
 }
 
 /* w32 implementation of get_cache for font backend.