diff options
| author | Dmitry Antipov | 2013-01-11 17:25:10 +0400 |
|---|---|---|
| committer | Dmitry Antipov | 2013-01-11 17:25:10 +0400 |
| commit | 6020559a093bf243be6cd6a866933b4368ea67cc (patch) | |
| tree | b722d61837c6f76447a76f58ac975f4d327ce1e4 /src/xml.c | |
| parent | 30818a239e7b1222ec776603aa29786638efbb47 (diff) | |
| download | emacs-6020559a093bf243be6cd6a866933b4368ea67cc.tar.gz emacs-6020559a093bf243be6cd6a866933b4368ea67cc.zip | |
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
| @@ -180,8 +180,7 @@ parse_region (Lisp_Object start, Lisp_Object end, Lisp_Object base_url, int html | |||
| 180 | xmlDoc *doc; | 180 | xmlDoc *doc; |
| 181 | Lisp_Object result = Qnil; | 181 | Lisp_Object result = Qnil; |
| 182 | const char *burl = ""; | 182 | const char *burl = ""; |
| 183 | ptrdiff_t bytes; | 183 | ptrdiff_t istart, iend, istart_byte, iend_byte; |
| 184 | ptrdiff_t istart, iend; | ||
| 185 | 184 | ||
| 186 | fn_xmlCheckVersion (LIBXML_VERSION); | 185 | fn_xmlCheckVersion (LIBXML_VERSION); |
| 187 | 186 | ||
| @@ -189,9 +188,11 @@ parse_region (Lisp_Object start, Lisp_Object end, Lisp_Object base_url, int html | |||
| 189 | 188 | ||
| 190 | istart = XINT (start); | 189 | istart = XINT (start); |
| 191 | iend = XINT (end); | 190 | iend = XINT (end); |
| 191 | istart_byte = CHAR_TO_BYTE (istart); | ||
| 192 | iend_byte = CHAR_TO_BYTE (iend); | ||
| 192 | 193 | ||
| 193 | if (istart < GPT && GPT < iend) | 194 | if (istart < GPT && GPT < iend) |
| 194 | move_gap (iend); | 195 | move_gap_both (iend, iend_byte); |
| 195 | 196 | ||
| 196 | if (! NILP (base_url)) | 197 | if (! NILP (base_url)) |
| 197 | { | 198 | { |
| @@ -199,17 +200,15 @@ parse_region (Lisp_Object start, Lisp_Object end, Lisp_Object base_url, int html | |||
| 199 | burl = SSDATA (base_url); | 200 | burl = SSDATA (base_url); |
| 200 | } | 201 | } |
| 201 | 202 | ||
| 202 | bytes = CHAR_TO_BYTE (iend) - CHAR_TO_BYTE (istart); | ||
| 203 | |||
| 204 | if (htmlp) | 203 | if (htmlp) |
| 205 | doc = fn_htmlReadMemory ((char *) BYTE_POS_ADDR (CHAR_TO_BYTE (istart)), | 204 | doc = fn_htmlReadMemory ((char *) BYTE_POS_ADDR (istart_byte), |
| 206 | bytes, burl, "utf-8", | 205 | iend_byte - istart_byte, burl, "utf-8", |
| 207 | HTML_PARSE_RECOVER|HTML_PARSE_NONET| | 206 | HTML_PARSE_RECOVER|HTML_PARSE_NONET| |
| 208 | HTML_PARSE_NOWARNING|HTML_PARSE_NOERROR| | 207 | HTML_PARSE_NOWARNING|HTML_PARSE_NOERROR| |
| 209 | HTML_PARSE_NOBLANKS); | 208 | HTML_PARSE_NOBLANKS); |
| 210 | else | 209 | else |
| 211 | doc = fn_xmlReadMemory ((char *) BYTE_POS_ADDR (CHAR_TO_BYTE (istart)), | 210 | doc = fn_xmlReadMemory ((char *) BYTE_POS_ADDR (istart_byte), |
| 212 | bytes, burl, "utf-8", | 211 | iend_byte - istart_byte, burl, "utf-8", |
| 213 | XML_PARSE_NONET|XML_PARSE_NOWARNING| | 212 | XML_PARSE_NONET|XML_PARSE_NOWARNING| |
| 214 | XML_PARSE_NOBLANKS |XML_PARSE_NOERROR); | 213 | XML_PARSE_NOBLANKS |XML_PARSE_NOERROR); |
| 215 | 214 | ||