diff options
| author | Dmitry Antipov | 2014-07-10 08:35:55 +0400 |
|---|---|---|
| committer | Dmitry Antipov | 2014-07-10 08:35:55 +0400 |
| commit | 80fb41cd90467782f4cfb21074aaa4f95308985e (patch) | |
| tree | 00ffd4871657cc09edb7d61e6de233d753c1b7d5 /src | |
| parent | 09880d8533e588da3388263f8c2360eb28ccc878 (diff) | |
| download | emacs-80fb41cd90467782f4cfb21074aaa4f95308985e.tar.gz emacs-80fb41cd90467782f4cfb21074aaa4f95308985e.zip | |
* coding.h (struct coding_system): Remove 'error_positions' (unused)
and 'errors' (set but unused) fields. Use bitfields for 'eol_seen',
'mode', 'common_flags' and 'result' fields, adjust layout to avoid
extra padding and shrink struct coding_system by 56 bytes (x86_64).
* coding.c (decode_coding_utf_8, decode_coding_utf_16)
(decode_coding_emacs_mule, decode_coding_iso_2022, decode_coding_sjis)
(decode_coding_big5, decode_coding_charset, decode_coding)
(encode_coding): Adjust users.
Diffstat (limited to 'src')
| -rw-r--r-- | src/ChangeLog | 11 | ||||
| -rw-r--r-- | src/coding.c | 10 | ||||
| -rw-r--r-- | src/coding.h | 61 |
3 files changed, 39 insertions, 43 deletions
diff --git a/src/ChangeLog b/src/ChangeLog index bcd004d9677..541697c5567 100644 --- a/src/ChangeLog +++ b/src/ChangeLog | |||
| @@ -1,3 +1,14 @@ | |||
| 1 | 2014-07-10 Dmitry Antipov <dmantipov@yandex.ru> | ||
| 2 | |||
| 3 | * coding.h (struct coding_system): Remove 'error_positions' (unused) | ||
| 4 | and 'errors' (set but unused) fields. Use bitfields for 'eol_seen', | ||
| 5 | 'mode', 'common_flags' and 'result' fields, adjust layout to avoid | ||
| 6 | extra padding and shrink struct coding_system by 56 bytes (x86_64). | ||
| 7 | * coding.c (decode_coding_utf_8, decode_coding_utf_16) | ||
| 8 | (decode_coding_emacs_mule, decode_coding_iso_2022, decode_coding_sjis) | ||
| 9 | (decode_coding_big5, decode_coding_charset, decode_coding) | ||
| 10 | (encode_coding): Adjust users. | ||
| 11 | |||
| 1 | 2014-07-09 Paul Eggert <eggert@cs.ucla.edu> | 12 | 2014-07-09 Paul Eggert <eggert@cs.ucla.edu> |
| 2 | 13 | ||
| 3 | * syntax.c (back_comment): Use more-natural location for label. | 14 | * syntax.c (back_comment): Use more-natural location for label. |
diff --git a/src/coding.c b/src/coding.c index 5e7a676aecd..523a6bf0f27 100644 --- a/src/coding.c +++ b/src/coding.c | |||
| @@ -1486,7 +1486,6 @@ decode_coding_utf_8 (struct coding_system *coding) | |||
| 1486 | consumed_chars = consumed_chars_base; | 1486 | consumed_chars = consumed_chars_base; |
| 1487 | ONE_MORE_BYTE (c); | 1487 | ONE_MORE_BYTE (c); |
| 1488 | *charbuf++ = ASCII_CHAR_P (c) ? c : BYTE8_TO_CHAR (c); | 1488 | *charbuf++ = ASCII_CHAR_P (c) ? c : BYTE8_TO_CHAR (c); |
| 1489 | coding->errors++; | ||
| 1490 | } | 1489 | } |
| 1491 | 1490 | ||
| 1492 | no_more_source: | 1491 | no_more_source: |
| @@ -1685,7 +1684,6 @@ decode_coding_utf_16 (struct coding_system *coding) | |||
| 1685 | /* The first two bytes are not BOM. Treat them as bytes | 1684 | /* The first two bytes are not BOM. Treat them as bytes |
| 1686 | for a normal character. */ | 1685 | for a normal character. */ |
| 1687 | src = src_base; | 1686 | src = src_base; |
| 1688 | coding->errors++; | ||
| 1689 | } | 1687 | } |
| 1690 | CODING_UTF_16_BOM (coding) = utf_without_bom; | 1688 | CODING_UTF_16_BOM (coding) = utf_without_bom; |
| 1691 | } | 1689 | } |
| @@ -1742,7 +1740,6 @@ decode_coding_utf_16 (struct coding_system *coding) | |||
| 1742 | c1 = surrogate & 0xFF, c2 = surrogate >> 8; | 1740 | c1 = surrogate & 0xFF, c2 = surrogate >> 8; |
| 1743 | *charbuf++ = c1; | 1741 | *charbuf++ = c1; |
| 1744 | *charbuf++ = c2; | 1742 | *charbuf++ = c2; |
| 1745 | coding->errors++; | ||
| 1746 | if (UTF_16_HIGH_SURROGATE_P (c)) | 1743 | if (UTF_16_HIGH_SURROGATE_P (c)) |
| 1747 | CODING_UTF_16_SURROGATE (coding) = surrogate = c; | 1744 | CODING_UTF_16_SURROGATE (coding) = surrogate = c; |
| 1748 | else | 1745 | else |
| @@ -2598,7 +2595,6 @@ decode_coding_emacs_mule (struct coding_system *coding) | |||
| 2598 | ONE_MORE_BYTE (c); | 2595 | ONE_MORE_BYTE (c); |
| 2599 | *charbuf++ = ASCII_CHAR_P (c) ? c : BYTE8_TO_CHAR (c); | 2596 | *charbuf++ = ASCII_CHAR_P (c) ? c : BYTE8_TO_CHAR (c); |
| 2600 | char_offset++; | 2597 | char_offset++; |
| 2601 | coding->errors++; | ||
| 2602 | } | 2598 | } |
| 2603 | 2599 | ||
| 2604 | no_more_source: | 2600 | no_more_source: |
| @@ -4006,7 +4002,6 @@ decode_coding_iso_2022 (struct coding_system *coding) | |||
| 4006 | ONE_MORE_BYTE (c); | 4002 | ONE_MORE_BYTE (c); |
| 4007 | *charbuf++ = c < 0 ? -c : ASCII_CHAR_P (c) ? c : BYTE8_TO_CHAR (c); | 4003 | *charbuf++ = c < 0 ? -c : ASCII_CHAR_P (c) ? c : BYTE8_TO_CHAR (c); |
| 4008 | char_offset++; | 4004 | char_offset++; |
| 4009 | coding->errors++; | ||
| 4010 | /* Reset the invocation and designation status to the safest | 4005 | /* Reset the invocation and designation status to the safest |
| 4011 | one; i.e. designate ASCII to the graphic register 0, and | 4006 | one; i.e. designate ASCII to the graphic register 0, and |
| 4012 | invoke that register to the graphic plane 0. This typically | 4007 | invoke that register to the graphic plane 0. This typically |
| @@ -4837,7 +4832,6 @@ decode_coding_sjis (struct coding_system *coding) | |||
| 4837 | ONE_MORE_BYTE (c); | 4832 | ONE_MORE_BYTE (c); |
| 4838 | *charbuf++ = c < 0 ? -c : BYTE8_TO_CHAR (c); | 4833 | *charbuf++ = c < 0 ? -c : BYTE8_TO_CHAR (c); |
| 4839 | char_offset++; | 4834 | char_offset++; |
| 4840 | coding->errors++; | ||
| 4841 | } | 4835 | } |
| 4842 | 4836 | ||
| 4843 | no_more_source: | 4837 | no_more_source: |
| @@ -4933,7 +4927,6 @@ decode_coding_big5 (struct coding_system *coding) | |||
| 4933 | ONE_MORE_BYTE (c); | 4927 | ONE_MORE_BYTE (c); |
| 4934 | *charbuf++ = c < 0 ? -c : BYTE8_TO_CHAR (c); | 4928 | *charbuf++ = c < 0 ? -c : BYTE8_TO_CHAR (c); |
| 4935 | char_offset++; | 4929 | char_offset++; |
| 4936 | coding->errors++; | ||
| 4937 | } | 4930 | } |
| 4938 | 4931 | ||
| 4939 | no_more_source: | 4932 | no_more_source: |
| @@ -5642,7 +5635,6 @@ decode_coding_charset (struct coding_system *coding) | |||
| 5642 | ONE_MORE_BYTE (c); | 5635 | ONE_MORE_BYTE (c); |
| 5643 | *charbuf++ = c < 0 ? -c : ASCII_CHAR_P (c) ? c : BYTE8_TO_CHAR (c); | 5636 | *charbuf++ = c < 0 ? -c : ASCII_CHAR_P (c) ? c : BYTE8_TO_CHAR (c); |
| 5644 | char_offset++; | 5637 | char_offset++; |
| 5645 | coding->errors++; | ||
| 5646 | } | 5638 | } |
| 5647 | 5639 | ||
| 5648 | no_more_source: | 5640 | no_more_source: |
| @@ -7375,7 +7367,6 @@ decode_coding (struct coding_system *coding) | |||
| 7375 | coding->produced = coding->produced_char = 0; | 7367 | coding->produced = coding->produced_char = 0; |
| 7376 | coding->chars_at_source = 0; | 7368 | coding->chars_at_source = 0; |
| 7377 | record_conversion_result (coding, CODING_RESULT_SUCCESS); | 7369 | record_conversion_result (coding, CODING_RESULT_SUCCESS); |
| 7378 | coding->errors = 0; | ||
| 7379 | 7370 | ||
| 7380 | ALLOC_CONVERSION_WORK_AREA (coding, coding->src_bytes); | 7371 | ALLOC_CONVERSION_WORK_AREA (coding, coding->src_bytes); |
| 7381 | 7372 | ||
| @@ -7771,7 +7762,6 @@ encode_coding (struct coding_system *coding) | |||
| 7771 | coding->consumed = coding->consumed_char = 0; | 7762 | coding->consumed = coding->consumed_char = 0; |
| 7772 | coding->produced = coding->produced_char = 0; | 7763 | coding->produced = coding->produced_char = 0; |
| 7773 | record_conversion_result (coding, CODING_RESULT_SUCCESS); | 7764 | record_conversion_result (coding, CODING_RESULT_SUCCESS); |
| 7774 | coding->errors = 0; | ||
| 7775 | 7765 | ||
| 7776 | ALLOC_CONVERSION_WORK_AREA (coding, coding->src_chars); | 7766 | ALLOC_CONVERSION_WORK_AREA (coding, coding->src_chars); |
| 7777 | 7767 | ||
diff --git a/src/coding.h b/src/coding.h index f3efcca031d..ffd839f4212 100644 --- a/src/coding.h +++ b/src/coding.h | |||
| @@ -434,11 +434,37 @@ struct coding_system | |||
| 434 | 434 | ||
| 435 | /* Flag bits of the coding system. The meaning of each bit is common | 435 | /* Flag bits of the coding system. The meaning of each bit is common |
| 436 | to all types of coding systems. */ | 436 | to all types of coding systems. */ |
| 437 | int common_flags; | 437 | unsigned common_flags : 14; |
| 438 | 438 | ||
| 439 | /* Mode bits of the coding system. See the comments of the macros | 439 | /* Mode bits of the coding system. See the comments of the macros |
| 440 | CODING_MODE_XXX. */ | 440 | CODING_MODE_XXX. */ |
| 441 | unsigned int mode; | 441 | unsigned mode : 5; |
| 442 | |||
| 443 | /* The following two members specify how binary 8-bit code 128..255 | ||
| 444 | are represented in source and destination text respectively. True | ||
| 445 | means they are represented by 2-byte sequence, false means they are | ||
| 446 | represented by 1-byte as is (see the comment in character.h). */ | ||
| 447 | bool_bf src_multibyte : 1; | ||
| 448 | bool_bf dst_multibyte : 1; | ||
| 449 | |||
| 450 | /* True if the source of conversion is not in the member | ||
| 451 | `charbuf', but at `src_object'. */ | ||
| 452 | bool_bf chars_at_source : 1; | ||
| 453 | |||
| 454 | /* Nonzero if the result of conversion is in `destination' | ||
| 455 | buffer rather than in `dst_object'. */ | ||
| 456 | bool_bf raw_destination : 1; | ||
| 457 | |||
| 458 | /* Set to true if charbuf contains an annotation. */ | ||
| 459 | bool_bf annotated : 1; | ||
| 460 | |||
| 461 | /* Used internally in coding.c. See the comment of detect_ascii. */ | ||
| 462 | unsigned eol_seen : 3; | ||
| 463 | |||
| 464 | /* Finish status of code conversion. */ | ||
| 465 | ENUM_BF (coding_result_code) result : 3; | ||
| 466 | |||
| 467 | int max_charset_id; | ||
| 442 | 468 | ||
| 443 | /* Detailed information specific to each type of coding system. */ | 469 | /* Detailed information specific to each type of coding system. */ |
| 444 | union | 470 | union |
| @@ -451,16 +477,8 @@ struct coding_system | |||
| 451 | struct undecided_spec undecided; | 477 | struct undecided_spec undecided; |
| 452 | } spec; | 478 | } spec; |
| 453 | 479 | ||
| 454 | int max_charset_id; | ||
| 455 | unsigned char *safe_charsets; | 480 | unsigned char *safe_charsets; |
| 456 | 481 | ||
| 457 | /* The following two members specify how binary 8-bit code 128..255 | ||
| 458 | are represented in source and destination text respectively. True | ||
| 459 | means they are represented by 2-byte sequence, false means they are | ||
| 460 | represented by 1-byte as is (see the comment in character.h). */ | ||
| 461 | bool_bf src_multibyte : 1; | ||
| 462 | bool_bf dst_multibyte : 1; | ||
| 463 | |||
| 464 | /* How may heading bytes we can skip for decoding. This is set to | 482 | /* How may heading bytes we can skip for decoding. This is set to |
| 465 | -1 in setup_coding_system, and updated by detect_coding. So, | 483 | -1 in setup_coding_system, and updated by detect_coding. So, |
| 466 | when this is equal to the byte length of the text being | 484 | when this is equal to the byte length of the text being |
| @@ -472,21 +490,9 @@ struct coding_system | |||
| 472 | sequence. Set by detect_coding_utf_8. */ | 490 | sequence. Set by detect_coding_utf_8. */ |
| 473 | ptrdiff_t detected_utf8_bytes, detected_utf8_chars; | 491 | ptrdiff_t detected_utf8_bytes, detected_utf8_chars; |
| 474 | 492 | ||
| 475 | /* Used internally in coding.c. See the comment of detect_ascii. */ | ||
| 476 | int eol_seen; | ||
| 477 | |||
| 478 | /* The following members are set by encoding/decoding routine. */ | 493 | /* The following members are set by encoding/decoding routine. */ |
| 479 | ptrdiff_t produced, produced_char, consumed, consumed_char; | 494 | ptrdiff_t produced, produced_char, consumed, consumed_char; |
| 480 | 495 | ||
| 481 | /* Number of error source data found in a decoding routine. */ | ||
| 482 | ptrdiff_t errors; | ||
| 483 | |||
| 484 | /* Store the positions of error source data. */ | ||
| 485 | ptrdiff_t *error_positions; | ||
| 486 | |||
| 487 | /* Finish status of code conversion. */ | ||
| 488 | enum coding_result_code result; | ||
| 489 | |||
| 490 | ptrdiff_t src_pos, src_pos_byte, src_chars, src_bytes; | 496 | ptrdiff_t src_pos, src_pos_byte, src_chars, src_bytes; |
| 491 | Lisp_Object src_object; | 497 | Lisp_Object src_object; |
| 492 | const unsigned char *source; | 498 | const unsigned char *source; |
| @@ -510,17 +516,6 @@ struct coding_system | |||
| 510 | int *charbuf; | 516 | int *charbuf; |
| 511 | int charbuf_size, charbuf_used; | 517 | int charbuf_size, charbuf_used; |
| 512 | 518 | ||
| 513 | /* True if the source of conversion is not in the member | ||
| 514 | `charbuf', but at `src_object'. */ | ||
| 515 | bool_bf chars_at_source : 1; | ||
| 516 | |||
| 517 | /* Nonzero if the result of conversion is in `destination' | ||
| 518 | buffer rather than in `dst_object'. */ | ||
| 519 | bool_bf raw_destination : 1; | ||
| 520 | |||
| 521 | /* Set to true if charbuf contains an annotation. */ | ||
| 522 | bool_bf annotated : 1; | ||
| 523 | |||
| 524 | unsigned char carryover[64]; | 519 | unsigned char carryover[64]; |
| 525 | int carryover_bytes; | 520 | int carryover_bytes; |
| 526 | 521 | ||