* 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 Dmitry Antipov <dmantipov@yandex.ru>
+
+ * 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 <eggert@cs.ucla.edu>
* process.c: Add sanity checks for file descriptors (Bug#17844).
#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 */
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)
{
/* 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;