diff options
author | Dmitry Antipov <dmantipov@yandex.ru> | 2013-01-11 17:25:10 +0400 |
---|---|---|
committer | Dmitry Antipov <dmantipov@yandex.ru> | 2013-01-11 17:25:10 +0400 |
commit | 6020559a093bf243be6cd6a866933b4368ea67cc (patch) | |
tree | b722d61837c6f76447a76f58ac975f4d327ce1e4 /src/xml.c | |
parent | 30818a239e7b1222ec776603aa29786638efbb47 (diff) | |
download | emacs-6020559a093bf243be6cd6a866933b4368ea67cc.tar.gz |
Avoid unnecessary byte position calculation for the gap movement.
Since all users of move_gap do CHAR_TO_BYTE for other purposes
anyway, all of them should use move_gap_both instead.
* lisp.h (move_gap): Remove prototype.
* insdel.c (move_gap): Remove.
(move_gap_both): Add eassert.
* editfns.c (Ftranspose_regions): Tweak to use move_gap_both.
* xml.c (parse_region): Likewise.
Diffstat (limited to 'src/xml.c')
-rw-r--r-- | src/xml.c | 17 |
1 files changed, 8 insertions, 9 deletions
diff --git a/src/xml.c b/src/xml.c index 5939c58a564..5a52b0c2a1e 100644 --- a/src/xml.c +++ b/src/xml.c @@ -180,8 +180,7 @@ parse_region (Lisp_Object start, Lisp_Object end, Lisp_Object base_url, int html xmlDoc *doc; Lisp_Object result = Qnil; const char *burl = ""; - ptrdiff_t bytes; - ptrdiff_t istart, iend; + ptrdiff_t istart, iend, istart_byte, iend_byte; fn_xmlCheckVersion (LIBXML_VERSION); @@ -189,9 +188,11 @@ parse_region (Lisp_Object start, Lisp_Object end, Lisp_Object base_url, int html istart = XINT (start); iend = XINT (end); + istart_byte = CHAR_TO_BYTE (istart); + iend_byte = CHAR_TO_BYTE (iend); if (istart < GPT && GPT < iend) - move_gap (iend); + move_gap_both (iend, iend_byte); if (! NILP (base_url)) { @@ -199,17 +200,15 @@ parse_region (Lisp_Object start, Lisp_Object end, Lisp_Object base_url, int html burl = SSDATA (base_url); } - bytes = CHAR_TO_BYTE (iend) - CHAR_TO_BYTE (istart); - if (htmlp) - doc = fn_htmlReadMemory ((char *) BYTE_POS_ADDR (CHAR_TO_BYTE (istart)), - bytes, burl, "utf-8", + doc = fn_htmlReadMemory ((char *) BYTE_POS_ADDR (istart_byte), + iend_byte - istart_byte, burl, "utf-8", HTML_PARSE_RECOVER|HTML_PARSE_NONET| HTML_PARSE_NOWARNING|HTML_PARSE_NOERROR| HTML_PARSE_NOBLANKS); else - doc = fn_xmlReadMemory ((char *) BYTE_POS_ADDR (CHAR_TO_BYTE (istart)), - bytes, burl, "utf-8", + doc = fn_xmlReadMemory ((char *) BYTE_POS_ADDR (istart_byte), + iend_byte - istart_byte, burl, "utf-8", XML_PARSE_NONET|XML_PARSE_NOWARNING| XML_PARSE_NOBLANKS |XML_PARSE_NOERROR); |