From f298de5264c86bbb76ccec727779dabe16e6b9c3 Mon Sep 17 00:00:00 2001 From: Dmitry Antipov Date: Tue, 8 Jul 2014 11:17:04 +0400 Subject: * 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. --- src/character.h | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'src/character.h') 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 */ -- cgit v1.2.1