From: Dmitry Antipov Date: Tue, 8 Jul 2014 07:17:04 +0000 (+0400) Subject: * chartab.c (char_table_translate): Move to... X-Git-Tag: emacs-25.0.90~2636^2~66 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=f298de5264c86bbb76ccec727779dabe16e6b9c3;p=emacs.git * chartab.c (char_table_translate): Move to... * character.h (char_table_translate): ... inline function here. Avoid Faref and assume that args are always valid. This helps to speedup search, which is especially important for a huge buffers. * lisp.h (char_table_translate): Remove prototype. --- diff --git a/src/ChangeLog b/src/ChangeLog index e854c2e1c39..c3ff9eb3a14 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,11 @@ +2014-07-08 Dmitry Antipov + + * chartab.c (char_table_translate): Move to... + * character.h (char_table_translate): ... inline function here. + Avoid Faref and assume that args are always valid. This helps to + speedup search, which is especially important for a huge buffers. + * lisp.h (char_table_translate): Remove prototype. + 2014-07-08 Paul Eggert * process.c: Add sanity checks for file descriptors (Bug#17844). diff --git a/src/character.h b/src/character.h index 18aad5b8f41..66cd4e47ef8 100644 --- a/src/character.h +++ b/src/character.h @@ -667,6 +667,20 @@ extern Lisp_Object string_escape_byte8 (Lisp_Object); #define GET_TRANSLATION_TABLE(id) \ (XCDR (XVECTOR (Vtranslation_table_vector)->contents[(id)])) +/* Look up the element in char table OBJ at index CH, and return it as + an integer. If the element is not a character, return CH itself. */ + +INLINE int +char_table_translate (Lisp_Object obj, int ch) +{ + /* This internal function is expected to be called with valid arguments, + so there is a eassert instead of CHECK_xxx for the sake of speed. */ + eassert (CHAR_VALID_P (ch)); + eassert (CHAR_TABLE_P (obj)); + obj = CHAR_TABLE_REF (obj, ch); + return CHARACTERP (obj) ? XINT (obj) : ch; +} + INLINE_HEADER_END #endif /* EMACS_CHARACTER_H */ diff --git a/src/chartab.c b/src/chartab.c index 3906ad30b37..50be063759a 100644 --- a/src/chartab.c +++ b/src/chartab.c @@ -663,19 +663,6 @@ or a character code. Return VALUE. */) return value; } -/* Look up the element in TABLE at index CH, and return it as an - integer. If the element is not a character, return CH itself. */ - -int -char_table_translate (Lisp_Object table, int ch) -{ - Lisp_Object value; - value = Faref (table, make_number (ch)); - if (! CHARACTERP (value)) - return ch; - return XINT (value); -} - static Lisp_Object optimize_sub_char_table (Lisp_Object table, Lisp_Object test) { diff --git a/src/lisp.h b/src/lisp.h index 6af390604d6..1c5bb14aafe 100644 --- a/src/lisp.h +++ b/src/lisp.h @@ -823,7 +823,6 @@ INLINE struct Lisp_Save_Value *XSAVE_VALUE (Lisp_Object); /* Defined in chartab.c. */ extern Lisp_Object char_table_ref (Lisp_Object, int); extern void char_table_set (Lisp_Object, int, Lisp_Object); -extern int char_table_translate (Lisp_Object, int); /* Defined in data.c. */ extern Lisp_Object Qarrayp, Qbufferp, Qbuffer_or_string_p, Qchar_table_p;