diff options
| author | Dmitry Antipov | 2015-01-14 15:56:46 +0300 |
|---|---|---|
| committer | Dmitry Antipov | 2015-01-14 15:56:46 +0300 |
| commit | 009836b97cdab2b79cfa26c83459db3fd91c94b0 (patch) | |
| tree | 503ad8ac2ab0acf4fc25d3146c46349166dcba9c /src | |
| parent | 99a1492b8a1269a9a5a280c0510d0ec00114a9a1 (diff) | |
| download | emacs-009836b97cdab2b79cfa26c83459db3fd91c94b0.tar.gz emacs-009836b97cdab2b79cfa26c83459db3fd91c94b0.zip | |
Never move gap in make_buffer_string_both.
* editfns.c (make_buffer_string_both): If requested range intersects
the gap, don't move the latter but copy in two regions, thus avoiding
unnecessary relocation of buffer data.
Diffstat (limited to 'src')
| -rw-r--r-- | src/ChangeLog | 4 | ||||
| -rw-r--r-- | src/editfns.c | 25 |
2 files changed, 26 insertions, 3 deletions
diff --git a/src/ChangeLog b/src/ChangeLog index 4f7ef6ef03e..f07ad02272d 100644 --- a/src/ChangeLog +++ b/src/ChangeLog | |||
| @@ -21,6 +21,10 @@ | |||
| 21 | (Fencode_time): ... adjusted user. | 21 | (Fencode_time): ... adjusted user. |
| 22 | (Fset_time_zone_rule): Use decode_time_zone. | 22 | (Fset_time_zone_rule): Use decode_time_zone. |
| 23 | 23 | ||
| 24 | * editfns.c (make_buffer_string_both): If requested range intersects | ||
| 25 | the gap, don't move the latter but copy in two regions, thus avoiding | ||
| 26 | unnecessary relocation of buffer data. | ||
| 27 | |||
| 24 | 2015-01-14 Paul Eggert <eggert@cs.ucla.edu> | 28 | 2015-01-14 Paul Eggert <eggert@cs.ucla.edu> |
| 25 | 29 | ||
| 26 | Use bool for boolean in xmenu.c, xml.c | 30 | Use bool for boolean in xmenu.c, xml.c |
diff --git a/src/editfns.c b/src/editfns.c index 9a159ba6581..621e841c3f5 100644 --- a/src/editfns.c +++ b/src/editfns.c | |||
| @@ -2624,15 +2624,34 @@ make_buffer_string_both (ptrdiff_t start, ptrdiff_t start_byte, | |||
| 2624 | ptrdiff_t end, ptrdiff_t end_byte, bool props) | 2624 | ptrdiff_t end, ptrdiff_t end_byte, bool props) |
| 2625 | { | 2625 | { |
| 2626 | Lisp_Object result, tem, tem1; | 2626 | Lisp_Object result, tem, tem1; |
| 2627 | ptrdiff_t beg0, end0, beg1, end1, size; | ||
| 2627 | 2628 | ||
| 2628 | if (start < GPT && GPT < end) | 2629 | if (start_byte < GPT_BYTE && GPT_BYTE < end_byte) |
| 2629 | move_gap_both (start, start_byte); | 2630 | { |
| 2631 | /* Two regions, before and after the gap. */ | ||
| 2632 | beg0 = start_byte; | ||
| 2633 | end0 = GPT_BYTE; | ||
| 2634 | beg1 = GPT_BYTE + GAP_SIZE - BEG_BYTE; | ||
| 2635 | end1 = end_byte + GAP_SIZE - BEG_BYTE; | ||
| 2636 | } | ||
| 2637 | else | ||
| 2638 | { | ||
| 2639 | /* The only region. */ | ||
| 2640 | beg0 = start_byte; | ||
| 2641 | end0 = end_byte; | ||
| 2642 | beg1 = -1; | ||
| 2643 | end1 = -1; | ||
| 2644 | } | ||
| 2630 | 2645 | ||
| 2631 | if (! NILP (BVAR (current_buffer, enable_multibyte_characters))) | 2646 | if (! NILP (BVAR (current_buffer, enable_multibyte_characters))) |
| 2632 | result = make_uninit_multibyte_string (end - start, end_byte - start_byte); | 2647 | result = make_uninit_multibyte_string (end - start, end_byte - start_byte); |
| 2633 | else | 2648 | else |
| 2634 | result = make_uninit_string (end - start); | 2649 | result = make_uninit_string (end - start); |
| 2635 | memcpy (SDATA (result), BYTE_POS_ADDR (start_byte), end_byte - start_byte); | 2650 | |
| 2651 | size = end0 - beg0; | ||
| 2652 | memcpy (SDATA (result), BYTE_POS_ADDR (beg0), size); | ||
| 2653 | if (beg1 != -1) | ||
| 2654 | memcpy (SDATA (result) + size, BEG_ADDR + beg1, end1 - beg1); | ||
| 2636 | 2655 | ||
| 2637 | /* If desired, update and copy the text properties. */ | 2656 | /* If desired, update and copy the text properties. */ |
| 2638 | if (props) | 2657 | if (props) |