Commit e8df9267 authored by Dmitry Antipov's avatar Dmitry Antipov

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.
parent 09f4e3b0
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.
......
......@@ -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)
......
......@@ -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;
......
......@@ -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;
......
......@@ -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.
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment