aboutsummaryrefslogtreecommitdiffstats
path: root/src/editfns.c
diff options
context:
space:
mode:
authorDmitry Antipov2013-01-11 17:25:10 +0400
committerDmitry Antipov2013-01-11 17:25:10 +0400
commit6020559a093bf243be6cd6a866933b4368ea67cc (patch)
treeb722d61837c6f76447a76f58ac975f4d327ce1e4 /src/editfns.c
parent30818a239e7b1222ec776603aa29786638efbb47 (diff)
downloademacs-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/editfns.c')
-rw-r--r--src/editfns.c12
1 files changed, 7 insertions, 5 deletions
diff --git a/src/editfns.c b/src/editfns.c
index 26dfdac3ba8..64269bab8df 100644
--- a/src/editfns.c
+++ b/src/editfns.c
@@ -4522,7 +4522,7 @@ Transposing beyond buffer boundaries is an error. */)
4522 (Lisp_Object startr1, Lisp_Object endr1, Lisp_Object startr2, Lisp_Object endr2, Lisp_Object leave_markers) 4522 (Lisp_Object startr1, Lisp_Object endr1, Lisp_Object startr2, Lisp_Object endr2, Lisp_Object leave_markers)
4523{ 4523{
4524 register ptrdiff_t start1, end1, start2, end2; 4524 register ptrdiff_t start1, end1, start2, end2;
4525 ptrdiff_t start1_byte, start2_byte, len1_byte, len2_byte; 4525 ptrdiff_t start1_byte, start2_byte, len1_byte, len2_byte, end2_byte;
4526 ptrdiff_t gap, len1, len_mid, len2; 4526 ptrdiff_t gap, len1, len_mid, len2;
4527 unsigned char *start1_addr, *start2_addr, *temp; 4527 unsigned char *start1_addr, *start2_addr, *temp;
4528 4528
@@ -4583,20 +4583,22 @@ Transposing beyond buffer boundaries is an error. */)
4583 the gap the minimum distance to get it out of the way, and then 4583 the gap the minimum distance to get it out of the way, and then
4584 deal with an unbroken array. */ 4584 deal with an unbroken array. */
4585 4585
4586 start1_byte = CHAR_TO_BYTE (start1);
4587 end2_byte = CHAR_TO_BYTE (end2);
4588
4586 /* Make sure the gap won't interfere, by moving it out of the text 4589 /* Make sure the gap won't interfere, by moving it out of the text
4587 we will operate on. */ 4590 we will operate on. */
4588 if (start1 < gap && gap < end2) 4591 if (start1 < gap && gap < end2)
4589 { 4592 {
4590 if (gap - start1 < end2 - gap) 4593 if (gap - start1 < end2 - gap)
4591 move_gap (start1); 4594 move_gap_both (start1, start1_byte);
4592 else 4595 else
4593 move_gap (end2); 4596 move_gap_both (end2, end2_byte);
4594 } 4597 }
4595 4598
4596 start1_byte = CHAR_TO_BYTE (start1);
4597 start2_byte = CHAR_TO_BYTE (start2); 4599 start2_byte = CHAR_TO_BYTE (start2);
4598 len1_byte = CHAR_TO_BYTE (end1) - start1_byte; 4600 len1_byte = CHAR_TO_BYTE (end1) - start1_byte;
4599 len2_byte = CHAR_TO_BYTE (end2) - start2_byte; 4601 len2_byte = end2_byte - start2_byte;
4600 4602
4601#ifdef BYTE_COMBINING_DEBUG 4603#ifdef BYTE_COMBINING_DEBUG
4602 if (end1 == start2) 4604 if (end1 == start2)