]> git.eshelyaron.com Git - emacs.git/commitdiff
* chartab.c (char_table_translate): Move to...
authorDmitry Antipov <dmantipov@yandex.ru>
Tue, 8 Jul 2014 07:17:04 +0000 (11:17 +0400)
committerDmitry Antipov <dmantipov@yandex.ru>
Tue, 8 Jul 2014 07:17:04 +0000 (11:17 +0400)
* 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/ChangeLog
src/character.h
src/chartab.c
src/lisp.h

index e854c2e1c39332611d02050bcdff539edc301980..c3ff9eb3a14a24f2442b63c7ba00548509a738b3 100644 (file)
@@ -1,3 +1,11 @@
+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).
index 18aad5b8f414cbe346b50c54945840c86ca34685..66cd4e47ef858f4f995026e7a5993d267e7953bb 100644 (file)
@@ -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 */
index 3906ad30b372ce4d8a86cc6ea106788e36f7d4c0..50be063759a3d9e290ce95451bc0690f802a0c93 100644 (file)
@@ -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)
 {
index 6af390604d664ea3c882c128a8b4b0ddf008a881..1c5bb14aafef7daefb9cfb8a27d1a7e29f67b9c3 100644 (file)
@@ -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;