# HG changeset patch # User Kenichi Handa # Date 1083156244 0 # Node ID 8d0c8d0ae419293ec9e97379dd53f10929c846c4 # Parent de927c4adfc4c02b1c560e5a7ffad1b2d7797928 (e_write): Short cut for the case of no encoding. diff -r de927c4adfc4 -r 8d0c8d0ae419 src/fileio.c --- 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) {