diff options
| author | Paul Eggert | 2017-07-05 17:51:31 -0700 |
|---|---|---|
| committer | Paul Eggert | 2017-07-05 18:59:31 -0700 |
| commit | d6662694d05be03fdd070353637dd22a324c8b7a (patch) | |
| tree | 3823cc192290478c041db63121c88afebfccbc13 /src/character.h | |
| parent | 24faf6b0d2fe990e9334dd2e3238f749fec87897 (diff) | |
| download | emacs-d6662694d05be03fdd070353637dd22a324c8b7a.tar.gz emacs-d6662694d05be03fdd070353637dd22a324c8b7a.zip | |
Convert hex digits more systematically
This makes the code a bit smaller and presumably faster, as
it substitutes a single lookup for conditional jumps.
* src/character.c (hexdigit): New constant.
(syms_of_character) [HEXDIGIT_IS_CONST]: Initialize it.
* src/character.h (HEXDIGIT_CONST, HEXDIGIT_IS_CONST): New macros.
(hexdigit): New decl.
(char_hexdigit): New inline function.
* src/charset.c: Do not include c-ctype.h.
* src/charset.c (read_hex):
* src/editfns.c (styled_format):
* src/image.c (xbm_scan):
* src/lread.c (read_escape):
* src/regex.c (ISXDIGIT) [emacs]:
Use char_hexdigit insted of doing it by hand.
Diffstat (limited to 'src/character.h')
| -rw-r--r-- | src/character.h | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/src/character.h b/src/character.h index 62d252e91ba..b073a0dd1e4 100644 --- a/src/character.h +++ b/src/character.h | |||
| @@ -700,6 +700,24 @@ char_table_translate (Lisp_Object obj, int ch) | |||
| 700 | return CHARACTERP (obj) ? XINT (obj) : ch; | 700 | return CHARACTERP (obj) ? XINT (obj) : ch; |
| 701 | } | 701 | } |
| 702 | 702 | ||
| 703 | #if defined __GNUC__ && !defined __STRICT_ANSI__ | ||
| 704 | # define HEXDIGIT_CONST const | ||
| 705 | # define HEXDIGIT_IS_CONST true | ||
| 706 | #else | ||
| 707 | # define HEXDIGIT_CONST | ||
| 708 | # define HEXDIGIT_IS_CONST false | ||
| 709 | #endif | ||
| 710 | extern signed char HEXDIGIT_CONST hexdigit[]; | ||
| 711 | |||
| 712 | /* If C is a hexadecimal digit ('0'-'9', 'a'-'f', 'A'-'F'), return its | ||
| 713 | value (0-15). Otherwise return -1. */ | ||
| 714 | |||
| 715 | INLINE int | ||
| 716 | char_hexdigit (int c) | ||
| 717 | { | ||
| 718 | return 0 <= c && c <= UCHAR_MAX ? hexdigit[c] : -1; | ||
| 719 | } | ||
| 720 | |||
| 703 | INLINE_HEADER_END | 721 | INLINE_HEADER_END |
| 704 | 722 | ||
| 705 | #endif /* EMACS_CHARACTER_H */ | 723 | #endif /* EMACS_CHARACTER_H */ |