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/image.c | |
| 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/image.c')
| -rw-r--r-- | src/image.c | 9 |
1 files changed, 2 insertions, 7 deletions
diff --git a/src/image.c b/src/image.c index 07c4769e9e3..6b748ba2af6 100644 --- a/src/image.c +++ b/src/image.c | |||
| @@ -2595,13 +2595,8 @@ xbm_scan (char **s, char *end, char *sval, int *ival) | |||
| 2595 | while (*s < end) | 2595 | while (*s < end) |
| 2596 | { | 2596 | { |
| 2597 | c = *(*s)++; | 2597 | c = *(*s)++; |
| 2598 | if (c_isdigit (c)) | 2598 | digit = char_hexdigit (c); |
| 2599 | digit = c - '0'; | 2599 | if (digit < 0) |
| 2600 | else if (c >= 'a' && c <= 'f') | ||
| 2601 | digit = c - 'a' + 10; | ||
| 2602 | else if (c >= 'A' && c <= 'F') | ||
| 2603 | digit = c - 'A' + 10; | ||
| 2604 | else | ||
| 2605 | break; | 2600 | break; |
| 2606 | value = 16 * value + digit; | 2601 | value = 16 * value + digit; |
| 2607 | } | 2602 | } |