[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Emacs-diffs] /srv/bzr/emacs/trunk r111484: Avoid unnecessary byte posit
From: |
Dmitry Antipov |
Subject: |
[Emacs-diffs] /srv/bzr/emacs/trunk r111484: Avoid unnecessary byte position calculation for the gap movement. |
Date: |
Fri, 11 Jan 2013 17:25:10 +0400 |
User-agent: |
Bazaar (2.5.0) |
------------------------------------------------------------
revno: 111484
committer: Dmitry Antipov <address@hidden>
branch nick: trunk
timestamp: Fri 2013-01-11 17:25:10 +0400
message:
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.
modified:
src/ChangeLog
src/editfns.c
src/insdel.c
src/lisp.h
src/xml.c
=== modified file 'src/ChangeLog'
--- a/src/ChangeLog 2013-01-11 02:40:58 +0000
+++ b/src/ChangeLog 2013-01-11 13:25:10 +0000
@@ -1,3 +1,14 @@
+2013-01-11 Dmitry Antipov <address@hidden>
+
+ 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.
+
2013-01-11 Paul Eggert <address@hidden>
emacsclient -t should not suspend Emacs server (Bug#13387)
=== modified file 'src/editfns.c'
--- a/src/editfns.c 2013-01-09 13:50:22 +0000
+++ b/src/editfns.c 2013-01-11 13:25:10 +0000
@@ -4522,7 +4522,7 @@
(Lisp_Object startr1, Lisp_Object endr1, Lisp_Object startr2, Lisp_Object
endr2, Lisp_Object leave_markers)
{
register ptrdiff_t start1, end1, start2, end2;
- ptrdiff_t start1_byte, start2_byte, len1_byte, len2_byte;
+ ptrdiff_t start1_byte, start2_byte, len1_byte, len2_byte, end2_byte;
ptrdiff_t gap, len1, len_mid, len2;
unsigned char *start1_addr, *start2_addr, *temp;
@@ -4583,20 +4583,22 @@
the gap the minimum distance to get it out of the way, and then
deal with an unbroken array. */
+ start1_byte = CHAR_TO_BYTE (start1);
+ end2_byte = CHAR_TO_BYTE (end2);
+
/* Make sure the gap won't interfere, by moving it out of the text
we will operate on. */
if (start1 < gap && gap < end2)
{
if (gap - start1 < end2 - gap)
- move_gap (start1);
+ move_gap_both (start1, start1_byte);
else
- move_gap (end2);
+ move_gap_both (end2, end2_byte);
}
- start1_byte = CHAR_TO_BYTE (start1);
start2_byte = CHAR_TO_BYTE (start2);
len1_byte = CHAR_TO_BYTE (end1) - start1_byte;
- len2_byte = CHAR_TO_BYTE (end2) - start2_byte;
+ len2_byte = end2_byte - start2_byte;
#ifdef BYTE_COMBINING_DEBUG
if (end1 == start2)
=== modified file 'src/insdel.c'
--- a/src/insdel.c 2013-01-09 14:08:49 +0000
+++ b/src/insdel.c 2013-01-11 13:25:10 +0000
@@ -84,21 +84,14 @@
#endif /* MARKER_DEBUG */
-/* Move gap to position CHARPOS.
- Note that this can quit! */
-
-void
-move_gap (ptrdiff_t charpos)
-{
- move_gap_both (charpos, CHAR_TO_BYTE (charpos));
-}
-
/* Move gap to byte position BYTEPOS, which is also char position CHARPOS.
Note that this can quit! */
void
move_gap_both (ptrdiff_t charpos, ptrdiff_t bytepos)
{
+ eassert (charpos == BYTE_TO_CHAR (bytepos)
+ && bytepos == CHAR_TO_BYTE (charpos));
if (bytepos < GPT_BYTE)
gap_left (charpos, bytepos, 0);
else if (bytepos > GPT_BYTE)
=== modified file 'src/lisp.h'
--- a/src/lisp.h 2013-01-11 02:40:58 +0000
+++ b/src/lisp.h 2013-01-11 13:25:10 +0000
@@ -2775,7 +2775,6 @@
/* Defined in insdel.c. */
extern Lisp_Object Qinhibit_modification_hooks;
-extern void move_gap (ptrdiff_t);
extern void move_gap_both (ptrdiff_t, ptrdiff_t);
extern _Noreturn void buffer_overflow (void);
extern void make_gap (ptrdiff_t);
=== modified file 'src/xml.c'
--- a/src/xml.c 2013-01-01 09:11:05 +0000
+++ b/src/xml.c 2013-01-11 13:25:10 +0000
@@ -180,8 +180,7 @@
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 @@
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 @@
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);
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Emacs-diffs] /srv/bzr/emacs/trunk r111484: Avoid unnecessary byte position calculation for the gap movement.,
Dmitry Antipov <=