Mercurial > emacs
changeset 89931:8d0c8d0ae419
(e_write): Short cut for the case of no encoding.
author | Kenichi Handa <handa@m17n.org> |
---|---|
date | Wed, 28 Apr 2004 12:44:04 +0000 |
parents | de927c4adfc4 |
children | 67cdf4445614 |
files | src/fileio.c |
diffstat | 1 files changed, 31 insertions(+), 8 deletions(-) [+] |
line wrap: on
line diff
--- a/src/fileio.c Tue Apr 27 10:54:16 2004 +0000 +++ b/src/fileio.c Wed Apr 28 12:44:04 2004 +0000 @@ -5362,18 +5362,41 @@ do { if (STRINGP (string)) - encode_coding_object (coding, string, - start, string_char_to_byte (string, start), - end, string_char_to_byte (string, end), Qt); + { + coding->src_multibyte = SCHARS (string) < SBYTES (string); + if (CODING_REQUIRE_ENCODING (coding)) + encode_coding_object (coding, string, + start, string_char_to_byte (string, start), + end, string_char_to_byte (string, end), Qt); + else + coding->dst_object = string, coding->produced = SBYTES (string); + } else - encode_coding_object (coding, Fcurrent_buffer (), - start, CHAR_TO_BYTE (start), - end, CHAR_TO_BYTE (end), Qt); + { + int start_byte = CHAR_TO_BYTE (start); + int end_byte = CHAR_TO_BYTE (end); + + coding->src_multibyte = (end - start) < (end_byte - start_byte); + if (CODING_REQUIRE_ENCODING (coding)) + encode_coding_object (coding, Fcurrent_buffer (), + start, CHAR_TO_BYTE (start), + end, CHAR_TO_BYTE (end), Qt); + else + { + coding->dst_object = Qnil; + coding->produced = end - start; + coding->dst_pos_byte = start_byte; + } + } if (coding->produced > 0) { - coding->produced -= emacs_write (desc, SDATA (coding->dst_object), - coding->produced); + coding->produced -= + emacs_write (desc, + STRINGP (coding->dst_object) + ? SDATA (coding->dst_object) + : BYTE_POS_ADDR (coding->dst_pos_byte), + coding->produced); if (coding->produced) {