diff options
| author | Dmitry Antipov | 2014-07-08 11:17:04 +0400 |
|---|---|---|
| committer | Dmitry Antipov | 2014-07-08 11:17:04 +0400 |
| commit | f298de5264c86bbb76ccec727779dabe16e6b9c3 (patch) | |
| tree | 05c709251b6982c042f04498510111e0fa03b82e /src | |
| parent | 12dc5429352223f7ba8314d2e16177036a762733 (diff) | |
| download | emacs-f298de5264c86bbb76ccec727779dabe16e6b9c3.tar.gz emacs-f298de5264c86bbb76ccec727779dabe16e6b9c3.zip | |
* 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.
Diffstat (limited to 'src')
| -rw-r--r-- | src/ChangeLog | 8 | ||||
| -rw-r--r-- | src/character.h | 14 | ||||
| -rw-r--r-- | src/chartab.c | 13 | ||||
| -rw-r--r-- | src/lisp.h | 1 |
4 files changed, 22 insertions, 14 deletions
diff --git a/src/ChangeLog b/src/ChangeLog index e854c2e1c39..c3ff9eb3a14 100644 --- a/src/ChangeLog +++ b/src/ChangeLog | |||
| @@ -1,3 +1,11 @@ | |||
| 1 | 2014-07-08 Dmitry Antipov <dmantipov@yandex.ru> | ||
| 2 | |||
| 3 | * chartab.c (char_table_translate): Move to... | ||
| 4 | * character.h (char_table_translate): ... inline function here. | ||
| 5 | Avoid Faref and assume that args are always valid. This helps to | ||
| 6 | speedup search, which is especially important for a huge buffers. | ||
| 7 | * lisp.h (char_table_translate): Remove prototype. | ||
| 8 | |||
| 1 | 2014-07-08 Paul Eggert <eggert@cs.ucla.edu> | 9 | 2014-07-08 Paul Eggert <eggert@cs.ucla.edu> |
| 2 | 10 | ||
| 3 | * process.c: Add sanity checks for file descriptors (Bug#17844). | 11 | * 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); | |||
| 667 | #define GET_TRANSLATION_TABLE(id) \ | 667 | #define GET_TRANSLATION_TABLE(id) \ |
| 668 | (XCDR (XVECTOR (Vtranslation_table_vector)->contents[(id)])) | 668 | (XCDR (XVECTOR (Vtranslation_table_vector)->contents[(id)])) |
| 669 | 669 | ||
| 670 | /* Look up the element in char table OBJ at index CH, and return it as | ||
| 671 | an integer. If the element is not a character, return CH itself. */ | ||
| 672 | |||
| 673 | INLINE int | ||
| 674 | char_table_translate (Lisp_Object obj, int ch) | ||
| 675 | { | ||
| 676 | /* This internal function is expected to be called with valid arguments, | ||
| 677 | so there is a eassert instead of CHECK_xxx for the sake of speed. */ | ||
| 678 | eassert (CHAR_VALID_P (ch)); | ||
| 679 | eassert (CHAR_TABLE_P (obj)); | ||
| 680 | obj = CHAR_TABLE_REF (obj, ch); | ||
| 681 | return CHARACTERP (obj) ? XINT (obj) : ch; | ||
| 682 | } | ||
| 683 | |||
| 670 | INLINE_HEADER_END | 684 | INLINE_HEADER_END |
| 671 | 685 | ||
| 672 | #endif /* EMACS_CHARACTER_H */ | 686 | #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. */) | |||
| 663 | return value; | 663 | return value; |
| 664 | } | 664 | } |
| 665 | 665 | ||
| 666 | /* Look up the element in TABLE at index CH, and return it as an | ||
| 667 | integer. If the element is not a character, return CH itself. */ | ||
| 668 | |||
| 669 | int | ||
| 670 | char_table_translate (Lisp_Object table, int ch) | ||
| 671 | { | ||
| 672 | Lisp_Object value; | ||
| 673 | value = Faref (table, make_number (ch)); | ||
| 674 | if (! CHARACTERP (value)) | ||
| 675 | return ch; | ||
| 676 | return XINT (value); | ||
| 677 | } | ||
| 678 | |||
| 679 | static Lisp_Object | 666 | static Lisp_Object |
| 680 | optimize_sub_char_table (Lisp_Object table, Lisp_Object test) | 667 | optimize_sub_char_table (Lisp_Object table, Lisp_Object test) |
| 681 | { | 668 | { |
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); | |||
| 823 | /* Defined in chartab.c. */ | 823 | /* Defined in chartab.c. */ |
| 824 | extern Lisp_Object char_table_ref (Lisp_Object, int); | 824 | extern Lisp_Object char_table_ref (Lisp_Object, int); |
| 825 | extern void char_table_set (Lisp_Object, int, Lisp_Object); | 825 | extern void char_table_set (Lisp_Object, int, Lisp_Object); |
| 826 | extern int char_table_translate (Lisp_Object, int); | ||
| 827 | 826 | ||
| 828 | /* Defined in data.c. */ | 827 | /* Defined in data.c. */ |
| 829 | extern Lisp_Object Qarrayp, Qbufferp, Qbuffer_or_string_p, Qchar_table_p; | 828 | extern Lisp_Object Qarrayp, Qbufferp, Qbuffer_or_string_p, Qchar_table_p; |