diff options
| author | Dmitry Antipov | 2012-07-11 11:37:39 +0400 |
|---|---|---|
| committer | Dmitry Antipov | 2012-07-11 11:37:39 +0400 |
| commit | e8df92674d0b73d4b32b467b9a1607e58b5f7a7d (patch) | |
| tree | 5b5d42310b419ece1ed4d0354d8c42f279b76daf /src | |
| parent | 09f4e3b0149e10d6d6a3d4915cf5c0a9768ded46 (diff) | |
| download | emacs-e8df92674d0b73d4b32b467b9a1607e58b5f7a7d.tar.gz emacs-e8df92674d0b73d4b32b467b9a1607e58b5f7a7d.zip | |
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.
Diffstat (limited to 'src')
| -rw-r--r-- | src/ChangeLog | 10 | ||||
| -rw-r--r-- | src/font.c | 16 | ||||
| -rw-r--r-- | src/lisp.h | 16 | ||||
| -rw-r--r-- | src/lread.c | 26 | ||||
| -rw-r--r-- | src/w32font.c | 20 |
5 files changed, 42 insertions, 46 deletions
diff --git a/src/ChangeLog b/src/ChangeLog index 5542d1db0f1..eb28180b7c3 100644 --- a/src/ChangeLog +++ b/src/ChangeLog | |||
| @@ -1,3 +1,13 @@ | |||
| 1 | 2012-07-11 Dmitry Antipov <dmantipov@yandex.ru> | ||
| 2 | |||
| 3 | Minor adjustments to interning code. | ||
| 4 | * lisp.h (intern, intern_c_string): Redefine as static inline | ||
| 5 | wrappers for intern_1 and intern_c_string_1, respectively. | ||
| 6 | (intern_1, intern_c_string_1): Rename prototypes. | ||
| 7 | * lread.c (intern_1, intern_c_string_1): Simplify Vobarray checking. | ||
| 8 | * font.c (font_intern_prop): Likewise. Adjust comment. | ||
| 9 | * w32font.c (intern_font_name): Likewise. | ||
| 10 | |||
| 1 | 2012-07-11 Andreas Schwab <schwab@linux-m68k.org> | 11 | 2012-07-11 Andreas Schwab <schwab@linux-m68k.org> |
| 2 | 12 | ||
| 3 | * gnutls.c (Fgnutls_boot): Properly parse :keylist argument. | 13 | * gnutls.c (Fgnutls_boot): Properly parse :keylist argument. |
diff --git a/src/font.c b/src/font.c index a57029b4af2..74f58878391 100644 --- a/src/font.c +++ b/src/font.c | |||
| @@ -264,18 +264,12 @@ font_intern_prop (const char *str, ptrdiff_t len, int force_symbol) | |||
| 264 | } | 264 | } |
| 265 | } | 265 | } |
| 266 | 266 | ||
| 267 | /* The following code is copied from the function intern (in | 267 | /* This code is similar to intern function from lread.c. */ |
| 268 | lread.c), and modified to suit our purpose. */ | 268 | obarray = check_obarray (Vobarray); |
| 269 | obarray = Vobarray; | ||
| 270 | if (!VECTORP (obarray) || ASIZE (obarray) == 0) | ||
| 271 | obarray = check_obarray (obarray); | ||
| 272 | parse_str_as_multibyte ((unsigned char *) str, len, &nchars, &nbytes); | 269 | parse_str_as_multibyte ((unsigned char *) str, len, &nchars, &nbytes); |
| 273 | if (len == nchars || len != nbytes) | 270 | tem = oblookup (obarray, str, |
| 274 | /* CONTENTS contains no multibyte sequences or contains an invalid | 271 | (len == nchars || len != nbytes) ? len : nchars, len); |
| 275 | multibyte sequence. We'll make a unibyte string. */ | 272 | |
| 276 | tem = oblookup (obarray, str, len, len); | ||
| 277 | else | ||
| 278 | tem = oblookup (obarray, str, nchars, len); | ||
| 279 | if (SYMBOLP (tem)) | 273 | if (SYMBOLP (tem)) |
| 280 | return tem; | 274 | return tem; |
| 281 | if (len == nchars || len != nbytes) | 275 | if (len == nchars || len != nbytes) |
diff --git a/src/lisp.h b/src/lisp.h index 5077713451e..e01f21e84d8 100644 --- a/src/lisp.h +++ b/src/lisp.h | |||
| @@ -2734,8 +2734,8 @@ extern ptrdiff_t evxprintf (char **, ptrdiff_t *, char const *, ptrdiff_t, | |||
| 2734 | extern Lisp_Object Qvariable_documentation, Qstandard_input; | 2734 | extern Lisp_Object Qvariable_documentation, Qstandard_input; |
| 2735 | extern Lisp_Object Qbackquote, Qcomma, Qcomma_at, Qcomma_dot, Qfunction; | 2735 | extern Lisp_Object Qbackquote, Qcomma, Qcomma_at, Qcomma_dot, Qfunction; |
| 2736 | extern Lisp_Object check_obarray (Lisp_Object); | 2736 | extern Lisp_Object check_obarray (Lisp_Object); |
| 2737 | extern Lisp_Object intern (const char *); | 2737 | extern Lisp_Object intern_1 (const char *, ptrdiff_t); |
| 2738 | extern Lisp_Object intern_c_string (const char *); | 2738 | extern Lisp_Object intern_c_string_1 (const char *, ptrdiff_t); |
| 2739 | extern Lisp_Object oblookup (Lisp_Object, const char *, ptrdiff_t, ptrdiff_t); | 2739 | extern Lisp_Object oblookup (Lisp_Object, const char *, ptrdiff_t, ptrdiff_t); |
| 2740 | #define LOADHIST_ATTACH(x) \ | 2740 | #define LOADHIST_ATTACH(x) \ |
| 2741 | do { \ | 2741 | do { \ |
| @@ -2752,6 +2752,18 @@ extern void init_obarray (void); | |||
| 2752 | extern void init_lread (void); | 2752 | extern void init_lread (void); |
| 2753 | extern void syms_of_lread (void); | 2753 | extern void syms_of_lread (void); |
| 2754 | 2754 | ||
| 2755 | static inline Lisp_Object | ||
| 2756 | intern (const char *str) | ||
| 2757 | { | ||
| 2758 | return intern_1 (str, strlen (str)); | ||
| 2759 | } | ||
| 2760 | |||
| 2761 | static inline Lisp_Object | ||
| 2762 | intern_c_string (const char *str) | ||
| 2763 | { | ||
| 2764 | return intern_c_string_1 (str, strlen (str)); | ||
| 2765 | } | ||
| 2766 | |||
| 2755 | /* Defined in eval.c. */ | 2767 | /* Defined in eval.c. */ |
| 2756 | extern Lisp_Object Qautoload, Qexit, Qinteractive, Qcommandp, Qmacro; | 2768 | extern Lisp_Object Qautoload, Qexit, Qinteractive, Qcommandp, Qmacro; |
| 2757 | extern Lisp_Object Qinhibit_quit, Qclosure; | 2769 | extern Lisp_Object Qinhibit_quit, Qclosure; |
diff --git a/src/lread.c b/src/lread.c index f74d44d12a8..13f41413196 100644 --- a/src/lread.c +++ b/src/lread.c | |||
| @@ -3652,32 +3652,20 @@ check_obarray (Lisp_Object obarray) | |||
| 3652 | interned in the current obarray. */ | 3652 | interned in the current obarray. */ |
| 3653 | 3653 | ||
| 3654 | Lisp_Object | 3654 | Lisp_Object |
| 3655 | intern (const char *str) | 3655 | intern_1 (const char *str, ptrdiff_t len) |
| 3656 | { | 3656 | { |
| 3657 | Lisp_Object tem; | 3657 | Lisp_Object obarray = check_obarray (Vobarray); |
| 3658 | ptrdiff_t len = strlen (str); | 3658 | Lisp_Object tem = oblookup (obarray, str, len, len); |
| 3659 | Lisp_Object obarray; | ||
| 3660 | 3659 | ||
| 3661 | obarray = Vobarray; | 3660 | return SYMBOLP (tem) ? tem : Fintern (make_string (str, len), obarray); |
| 3662 | if (!VECTORP (obarray) || ASIZE (obarray) == 0) | ||
| 3663 | obarray = check_obarray (obarray); | ||
| 3664 | tem = oblookup (obarray, str, len, len); | ||
| 3665 | if (SYMBOLP (tem)) | ||
| 3666 | return tem; | ||
| 3667 | return Fintern (make_string (str, len), obarray); | ||
| 3668 | } | 3661 | } |
| 3669 | 3662 | ||
| 3670 | Lisp_Object | 3663 | Lisp_Object |
| 3671 | intern_c_string (const char *str) | 3664 | intern_c_string_1 (const char *str, ptrdiff_t len) |
| 3672 | { | 3665 | { |
| 3673 | Lisp_Object tem; | 3666 | Lisp_Object obarray = check_obarray (Vobarray); |
| 3674 | ptrdiff_t len = strlen (str); | 3667 | Lisp_Object tem = oblookup (obarray, str, len, len); |
| 3675 | Lisp_Object obarray; | ||
| 3676 | 3668 | ||
| 3677 | obarray = Vobarray; | ||
| 3678 | if (!VECTORP (obarray) || ASIZE (obarray) == 0) | ||
| 3679 | obarray = check_obarray (obarray); | ||
| 3680 | tem = oblookup (obarray, str, len, len); | ||
| 3681 | if (SYMBOLP (tem)) | 3669 | if (SYMBOLP (tem)) |
| 3682 | return tem; | 3670 | return tem; |
| 3683 | 3671 | ||
diff --git a/src/w32font.c b/src/w32font.c index d2f8410f1de..0200d7ce074 100644 --- a/src/w32font.c +++ b/src/w32font.c | |||
| @@ -289,20 +289,12 @@ memq_no_quit (Lisp_Object elt, Lisp_Object list) | |||
| 289 | Lisp_Object | 289 | Lisp_Object |
| 290 | intern_font_name (char * string) | 290 | intern_font_name (char * string) |
| 291 | { | 291 | { |
| 292 | Lisp_Object obarray, tem, str; | 292 | Lisp_Object str = DECODE_SYSTEM (build_string (string)); |
| 293 | int len; | 293 | int len = SCHARS (str); |
| 294 | 294 | Lisp_Object obarray = check_obarray (Vobarray); | |
| 295 | str = DECODE_SYSTEM (build_string (string)); | 295 | Lisp_Object tem = oblookup (obarray, SDATA (str), len, len); |
| 296 | len = SCHARS (str); | 296 | /* This code is similar to intern function from lread.c. */ |
| 297 | 297 | return SYMBOLP (tem) ? tem : Fintern (str, obarray); | |
| 298 | /* The following code is copied from the function intern (in lread.c). */ | ||
| 299 | obarray = Vobarray; | ||
| 300 | if (!VECTORP (obarray) || ASIZE (obarray) == 0) | ||
| 301 | obarray = check_obarray (obarray); | ||
| 302 | tem = oblookup (obarray, SDATA (str), len, len); | ||
| 303 | if (SYMBOLP (tem)) | ||
| 304 | return tem; | ||
| 305 | return Fintern (str, obarray); | ||
| 306 | } | 298 | } |
| 307 | 299 | ||
| 308 | /* w32 implementation of get_cache for font backend. | 300 | /* w32 implementation of get_cache for font backend. |