aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorDmitry Antipov2012-08-08 16:12:40 +0400
committerDmitry Antipov2012-08-08 16:12:40 +0400
commit8707c1e56ca83a0a34785e451dcef428c60242fe (patch)
treef404532e675b2870620faafa8d94dacf618c1a22 /src
parentad8c997f72c95b7351eab4c8ea2ac8c667545e6f (diff)
downloademacs-8707c1e56ca83a0a34785e451dcef428c60242fe.tar.gz
emacs-8707c1e56ca83a0a34785e451dcef428c60242fe.zip
Inline functions to examine and change buffer intervals.
* alloc.c (mark_interval_tree): Remove. (MARK_INTERVAL_TREE): Simplify. (UNMARK_BALANCE_INTERVALS): Remove. Adjust users. * intervals.c (buffer_balance_intervals): New function. (graft_intervals_into_buffer): Adjust indentation. (set_intervals_multibyte): Simplify. * buffer.h (BUF_INTERVALS): Remove. (buffer_get_intervals, buffer_set_intervals): New function. * alloc.c, buffer.c, editfns.c, fileio.c, indent.c, insdel.c: * intervals.c, textprop.c: Adjust users.
Diffstat (limited to 'src')
-rw-r--r--src/ChangeLog14
-rw-r--r--src/alloc.c40
-rw-r--r--src/buffer.c8
-rw-r--r--src/buffer.h23
-rw-r--r--src/editfns.c2
-rw-r--r--src/fileio.c2
-rw-r--r--src/indent.c2
-rw-r--r--src/insdel.c19
-rw-r--r--src/intervals.c88
-rw-r--r--src/textprop.c10
10 files changed, 115 insertions, 93 deletions
diff --git a/src/ChangeLog b/src/ChangeLog
index 20bb917f1a1..9c6d4b4458d 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,5 +1,19 @@
12012-08-08 Dmitry Antipov <dmantipov@yandex.ru> 12012-08-08 Dmitry Antipov <dmantipov@yandex.ru>
2 2
3 Inline functions to examine and change buffer intervals.
4 * alloc.c (mark_interval_tree): Remove.
5 (MARK_INTERVAL_TREE): Simplify.
6 (UNMARK_BALANCE_INTERVALS): Remove. Adjust users.
7 * intervals.c (buffer_balance_intervals): New function.
8 (graft_intervals_into_buffer): Adjust indentation.
9 (set_intervals_multibyte): Simplify.
10 * buffer.h (BUF_INTERVALS): Remove.
11 (buffer_get_intervals, buffer_set_intervals): New function.
12 * alloc.c, buffer.c, editfns.c, fileio.c, indent.c, insdel.c:
13 * intervals.c, textprop.c: Adjust users.
14
152012-08-08 Dmitry Antipov <dmantipov@yandex.ru>
16
3 Inline functions to examine and change string intervals. 17 Inline functions to examine and change string intervals.
4 * lisp.h (STRING_INTERVALS, STRING_SET_INTERVALS): Remove. 18 * lisp.h (STRING_INTERVALS, STRING_SET_INTERVALS): Remove.
5 (string_get_intervals, string_set_intervals): New function. 19 (string_get_intervals, string_set_intervals): New function.
diff --git a/src/alloc.c b/src/alloc.c
index 95309f076d4..c93fcb564c7 100644
--- a/src/alloc.c
+++ b/src/alloc.c
@@ -1542,35 +1542,12 @@ mark_interval (register INTERVAL i, Lisp_Object dummy)
1542 mark_object (i->plist); 1542 mark_object (i->plist);
1543} 1543}
1544 1544
1545
1546/* Mark the interval tree rooted in TREE. Don't call this directly;
1547 use the macro MARK_INTERVAL_TREE instead. */
1548
1549static void
1550mark_interval_tree (register INTERVAL tree)
1551{
1552 /* No need to test if this tree has been marked already; this
1553 function is always called through the MARK_INTERVAL_TREE macro,
1554 which takes care of that. */
1555
1556 traverse_intervals_noorder (tree, mark_interval, Qnil);
1557}
1558
1559
1560/* Mark the interval tree rooted in I. */ 1545/* Mark the interval tree rooted in I. */
1561 1546
1562#define MARK_INTERVAL_TREE(i) \ 1547#define MARK_INTERVAL_TREE(i) \
1563 do { \ 1548 do { \
1564 if (i && !i->gcmarkbit) \ 1549 if (i && !i->gcmarkbit) \
1565 mark_interval_tree (i); \ 1550 traverse_intervals_noorder (i, mark_interval, Qnil); \
1566 } while (0)
1567
1568/* Unmark and rebalance interval tree rooted in I. */
1569
1570#define UNMARK_BALANCE_INTERVALS(i) \
1571 do { \
1572 if (i) \
1573 (i) = balance_intervals (i); \
1574 } while (0) 1551 } while (0)
1575 1552
1576/*********************************************************************** 1553/***********************************************************************
@@ -2101,8 +2078,8 @@ sweep_strings (void)
2101 /* String is live; unmark it and its intervals. */ 2078 /* String is live; unmark it and its intervals. */
2102 UNMARK_STRING (s); 2079 UNMARK_STRING (s);
2103 2080
2104 if (s->intervals) 2081 /* Do not use string_(set|get)_intervals here. */
2105 UNMARK_BALANCE_INTERVALS (s->intervals); 2082 s->intervals = balance_intervals (s->intervals);
2106 2083
2107 ++total_strings; 2084 ++total_strings;
2108 total_string_bytes += STRING_BYTES (s); 2085 total_string_bytes += STRING_BYTES (s);
@@ -5848,7 +5825,7 @@ mark_buffer (struct buffer *buffer)
5848 5825
5849 /* ...but there are some buffer-specific things. */ 5826 /* ...but there are some buffer-specific things. */
5850 5827
5851 MARK_INTERVAL_TREE (BUF_INTERVALS (buffer)); 5828 MARK_INTERVAL_TREE (buffer_get_intervals (buffer));
5852 5829
5853 /* For now, we just don't mark the undo_list. It's done later in 5830 /* For now, we just don't mark the undo_list. It's done later in
5854 a special way just before the sweep phase, and after stripping 5831 a special way just before the sweep phase, and after stripping
@@ -6587,7 +6564,8 @@ gc_sweep (void)
6587 else 6564 else
6588 { 6565 {
6589 VECTOR_UNMARK (buffer); 6566 VECTOR_UNMARK (buffer);
6590 UNMARK_BALANCE_INTERVALS (BUF_INTERVALS (buffer)); 6567 /* Do not use buffer_(set|get)_intervals here. */
6568 buffer->text->intervals = balance_intervals (buffer->text->intervals);
6591 total_buffers++; 6569 total_buffers++;
6592 prev = buffer, buffer = buffer->header.next.buffer; 6570 prev = buffer, buffer = buffer->header.next.buffer;
6593 } 6571 }
diff --git a/src/buffer.c b/src/buffer.c
index 395ca48680f..fab7330b195 100644
--- a/src/buffer.c
+++ b/src/buffer.c
@@ -360,7 +360,7 @@ even if it is dead. The return value is never nil. */)
360 BUF_CHARS_MODIFF (b) = 1; 360 BUF_CHARS_MODIFF (b) = 1;
361 BUF_OVERLAY_MODIFF (b) = 1; 361 BUF_OVERLAY_MODIFF (b) = 1;
362 BUF_SAVE_MODIFF (b) = 1; 362 BUF_SAVE_MODIFF (b) = 1;
363 BUF_INTERVALS (b) = NULL; 363 buffer_set_intervals (b, NULL);
364 BUF_UNCHANGED_MODIFIED (b) = 1; 364 BUF_UNCHANGED_MODIFIED (b) = 1;
365 BUF_OVERLAY_UNCHANGED_MODIFIED (b) = 1; 365 BUF_OVERLAY_UNCHANGED_MODIFIED (b) = 1;
366 BUF_END_UNCHANGED (b) = 0; 366 BUF_END_UNCHANGED (b) = 0;
@@ -1688,7 +1688,7 @@ cleaning up all windows currently displaying the buffer to be killed. */)
1688 m = next; 1688 m = next;
1689 } 1689 }
1690 BUF_MARKERS (b) = NULL; 1690 BUF_MARKERS (b) = NULL;
1691 BUF_INTERVALS (b) = NULL; 1691 buffer_set_intervals (b, NULL);
1692 1692
1693 /* Perhaps we should explicitly free the interval tree here... */ 1693 /* Perhaps we should explicitly free the interval tree here... */
1694 } 1694 }
@@ -4904,8 +4904,8 @@ init_buffer_once (void)
4904 /* No one will share the text with these buffers, but let's play it safe. */ 4904 /* No one will share the text with these buffers, but let's play it safe. */
4905 buffer_defaults.indirections = 0; 4905 buffer_defaults.indirections = 0;
4906 buffer_local_symbols.indirections = 0; 4906 buffer_local_symbols.indirections = 0;
4907 BUF_INTERVALS (&buffer_defaults) = NULL; 4907 buffer_set_intervals (&buffer_defaults, NULL);
4908 BUF_INTERVALS (&buffer_local_symbols) = NULL; 4908 buffer_set_intervals (&buffer_local_symbols, NULL);
4909 XSETPVECTYPESIZE (&buffer_defaults, PVEC_BUFFER, pvecsize); 4909 XSETPVECTYPESIZE (&buffer_defaults, PVEC_BUFFER, pvecsize);
4910 XSETBUFFER (Vbuffer_defaults, &buffer_defaults); 4910 XSETBUFFER (Vbuffer_defaults, &buffer_defaults);
4911 XSETPVECTYPESIZE (&buffer_local_symbols, PVEC_BUFFER, pvecsize); 4911 XSETPVECTYPESIZE (&buffer_local_symbols, PVEC_BUFFER, pvecsize);
diff --git a/src/buffer.h b/src/buffer.h
index 9618fc6ded1..986df8e6d32 100644
--- a/src/buffer.h
+++ b/src/buffer.h
@@ -193,9 +193,6 @@ INLINE_HEADER_BEGIN
193/* FIXME: should we move this into ->text->auto_save_modiff? */ 193/* FIXME: should we move this into ->text->auto_save_modiff? */
194#define BUF_AUTOSAVE_MODIFF(buf) ((buf)->auto_save_modified) 194#define BUF_AUTOSAVE_MODIFF(buf) ((buf)->auto_save_modified)
195 195
196/* Interval tree of buffer. */
197#define BUF_INTERVALS(buf) ((buf)->text->intervals)
198
199/* Marker chain of buffer. */ 196/* Marker chain of buffer. */
200#define BUF_MARKERS(buf) ((buf)->text->markers) 197#define BUF_MARKERS(buf) ((buf)->text->markers)
201 198
@@ -951,7 +948,25 @@ extern void mmap_set_vars (int);
951extern Lisp_Object Qbefore_change_functions; 948extern Lisp_Object Qbefore_change_functions;
952extern Lisp_Object Qafter_change_functions; 949extern Lisp_Object Qafter_change_functions;
953extern Lisp_Object Qfirst_change_hook; 950extern Lisp_Object Qfirst_change_hook;
954 951
952/* Get text properties of B. */
953
954BUFFER_INLINE INTERVAL
955buffer_get_intervals (struct buffer *b)
956{
957 eassert (b->text != NULL);
958 return b->text->intervals;
959}
960
961/* Set text properties of B to I. */
962
963BUFFER_INLINE void
964buffer_set_intervals (struct buffer *b, INTERVAL i)
965{
966 eassert (b->text != NULL);
967 b->text->intervals = i;
968}
969
955/* Return character code of multi-byte form at byte position POS. If POS 970/* Return character code of multi-byte form at byte position POS. If POS
956 doesn't point the head of valid multi-byte form, only the byte at 971 doesn't point the head of valid multi-byte form, only the byte at
957 POS is returned. No range checking. 972 POS is returned. No range checking.
diff --git a/src/editfns.c b/src/editfns.c
index 3bcc1a57a7e..aca34482fb2 100644
--- a/src/editfns.c
+++ b/src/editfns.c
@@ -4527,7 +4527,7 @@ Transposing beyond buffer boundaries is an error. */)
4527 Lisp_Object buf; 4527 Lisp_Object buf;
4528 4528
4529 XSETBUFFER (buf, current_buffer); 4529 XSETBUFFER (buf, current_buffer);
4530 cur_intv = BUF_INTERVALS (current_buffer); 4530 cur_intv = buffer_get_intervals (current_buffer);
4531 4531
4532 validate_region (&startr1, &endr1); 4532 validate_region (&startr1, &endr1);
4533 validate_region (&startr2, &endr2); 4533 validate_region (&startr2, &endr2);
diff --git a/src/fileio.c b/src/fileio.c
index 7639c2f0b33..9fe7437669c 100644
--- a/src/fileio.c
+++ b/src/fileio.c
@@ -3145,7 +3145,7 @@ decide_coding_unwind (Lisp_Object unwind_data)
3145 set_buffer_internal (XBUFFER (buffer)); 3145 set_buffer_internal (XBUFFER (buffer));
3146 adjust_markers_for_delete (BEG, BEG_BYTE, Z, Z_BYTE); 3146 adjust_markers_for_delete (BEG, BEG_BYTE, Z, Z_BYTE);
3147 adjust_overlays_for_delete (BEG, Z - BEG); 3147 adjust_overlays_for_delete (BEG, Z - BEG);
3148 BUF_INTERVALS (current_buffer) = NULL; 3148 buffer_set_intervals (current_buffer, NULL);
3149 TEMP_SET_PT_BOTH (BEG, BEG_BYTE); 3149 TEMP_SET_PT_BOTH (BEG, BEG_BYTE);
3150 3150
3151 /* Now we are safe to change the buffer's multibyteness directly. */ 3151 /* Now we are safe to change the buffer's multibyteness directly. */
diff --git a/src/indent.c b/src/indent.c
index 928d61196a5..6b7e79fb7a5 100644
--- a/src/indent.c
+++ b/src/indent.c
@@ -336,7 +336,7 @@ current_column (void)
336 336
337 /* If the buffer has overlays, text properties, 337 /* If the buffer has overlays, text properties,
338 or multibyte characters, use a more general algorithm. */ 338 or multibyte characters, use a more general algorithm. */
339 if (BUF_INTERVALS (current_buffer) 339 if (buffer_get_intervals (current_buffer)
340 || current_buffer->overlays_before 340 || current_buffer->overlays_before
341 || current_buffer->overlays_after 341 || current_buffer->overlays_after
342 || Z != Z_BYTE) 342 || Z != Z_BYTE)
diff --git a/src/insdel.c b/src/insdel.c
index 1a66cfc6080..ec0d3b31f70 100644
--- a/src/insdel.c
+++ b/src/insdel.c
@@ -844,10 +844,10 @@ insert_1_both (const char *string,
844 PT + nchars, PT_BYTE + nbytes, 844 PT + nchars, PT_BYTE + nbytes,
845 before_markers); 845 before_markers);
846 846
847 if (BUF_INTERVALS (current_buffer)) 847 if (buffer_get_intervals (current_buffer))
848 offset_intervals (current_buffer, PT, nchars); 848 offset_intervals (current_buffer, PT, nchars);
849 849
850 if (!inherit && BUF_INTERVALS (current_buffer)) 850 if (!inherit && buffer_get_intervals (current_buffer))
851 set_text_properties (make_number (PT), make_number (PT + nchars), 851 set_text_properties (make_number (PT), make_number (PT + nchars),
852 Qnil, Qnil, Qnil); 852 Qnil, Qnil, Qnil);
853 853
@@ -1017,7 +1017,7 @@ insert_from_gap (ptrdiff_t nchars, ptrdiff_t nbytes)
1017 adjust_markers_for_insert (GPT - nchars, GPT_BYTE - nbytes, 1017 adjust_markers_for_insert (GPT - nchars, GPT_BYTE - nbytes,
1018 GPT, GPT_BYTE, 0); 1018 GPT, GPT_BYTE, 0);
1019 1019
1020 if (BUF_INTERVALS (current_buffer)) 1020 if (buffer_get_intervals (current_buffer))
1021 { 1021 {
1022 offset_intervals (current_buffer, GPT - nchars, nchars); 1022 offset_intervals (current_buffer, GPT - nchars, nchars);
1023 graft_intervals_into_buffer (NULL, GPT - nchars, nchars, 1023 graft_intervals_into_buffer (NULL, GPT - nchars, nchars,
@@ -1157,11 +1157,11 @@ insert_from_buffer_1 (struct buffer *buf,
1157 PT_BYTE + outgoing_nbytes, 1157 PT_BYTE + outgoing_nbytes,
1158 0); 1158 0);
1159 1159
1160 if (BUF_INTERVALS (current_buffer)) 1160 if (buffer_get_intervals (current_buffer))
1161 offset_intervals (current_buffer, PT, nchars); 1161 offset_intervals (current_buffer, PT, nchars);
1162 1162
1163 /* Get the intervals for the part of the string we are inserting. */ 1163 /* Get the intervals for the part of the string we are inserting. */
1164 intervals = BUF_INTERVALS (buf); 1164 intervals = buffer_get_intervals (buf);
1165 if (nchars < BUF_Z (buf) - BUF_BEG (buf)) 1165 if (nchars < BUF_Z (buf) - BUF_BEG (buf))
1166 { 1166 {
1167 if (buf == current_buffer && PT <= from) 1167 if (buf == current_buffer && PT <= from)
@@ -1225,10 +1225,9 @@ adjust_after_replace (ptrdiff_t from, ptrdiff_t from_byte,
1225 adjust_overlays_for_insert (from, len - nchars_del); 1225 adjust_overlays_for_insert (from, len - nchars_del);
1226 else if (len < nchars_del) 1226 else if (len < nchars_del)
1227 adjust_overlays_for_delete (from, nchars_del - len); 1227 adjust_overlays_for_delete (from, nchars_del - len);
1228 if (BUF_INTERVALS (current_buffer)) 1228
1229 { 1229 if (buffer_get_intervals (current_buffer))
1230 offset_intervals (current_buffer, from, len - nchars_del); 1230 offset_intervals (current_buffer, from, len - nchars_del);
1231 }
1232 1231
1233 if (from < PT) 1232 if (from < PT)
1234 adjust_point (len - nchars_del, len_byte - nbytes_del); 1233 adjust_point (len - nchars_del, len_byte - nbytes_del);
@@ -1823,7 +1822,7 @@ prepare_to_modify_buffer (ptrdiff_t start, ptrdiff_t end,
1823 if (XBUFFER (XWINDOW (selected_window)->buffer) != current_buffer) 1822 if (XBUFFER (XWINDOW (selected_window)->buffer) != current_buffer)
1824 ++windows_or_buffers_changed; 1823 ++windows_or_buffers_changed;
1825 1824
1826 if (BUF_INTERVALS (current_buffer)) 1825 if (buffer_get_intervals (current_buffer))
1827 { 1826 {
1828 if (preserve_ptr) 1827 if (preserve_ptr)
1829 { 1828 {
diff --git a/src/intervals.c b/src/intervals.c
index 64e54eb7b43..e9c3929670e 100644
--- a/src/intervals.c
+++ b/src/intervals.c
@@ -77,7 +77,7 @@ create_root_interval (Lisp_Object parent)
77 new->total_length = (BUF_Z (XBUFFER (parent)) 77 new->total_length = (BUF_Z (XBUFFER (parent))
78 - BUF_BEG (XBUFFER (parent))); 78 - BUF_BEG (XBUFFER (parent)));
79 eassert (0 <= TOTAL_LENGTH (new)); 79 eassert (0 <= TOTAL_LENGTH (new));
80 BUF_INTERVALS (XBUFFER (parent)) = new; 80 buffer_set_intervals (XBUFFER (parent), new);
81 new->position = BEG; 81 new->position = BEG;
82 } 82 }
83 else if (STRINGP (parent)) 83 else if (STRINGP (parent))
@@ -453,7 +453,7 @@ balance_possible_root_interval (register INTERVAL interval)
453 if (have_parent) 453 if (have_parent)
454 { 454 {
455 if (BUFFERP (parent)) 455 if (BUFFERP (parent))
456 BUF_INTERVALS (XBUFFER (parent)) = interval; 456 buffer_set_intervals (XBUFFER (parent), interval);
457 else if (STRINGP (parent)) 457 else if (STRINGP (parent))
458 string_set_intervals (parent, interval); 458 string_set_intervals (parent, interval);
459 } 459 }
@@ -483,6 +483,19 @@ balance_intervals (INTERVAL tree)
483 return tree ? balance_intervals_internal (tree) : NULL; 483 return tree ? balance_intervals_internal (tree) : NULL;
484} 484}
485 485
486/* Rebalance text properties of B. */
487
488static void
489buffer_balance_intervals (struct buffer *b)
490{
491 INTERVAL i;
492
493 eassert (b != NULL);
494 i = buffer_get_intervals (b);
495 if (i)
496 buffer_set_intervals (b, balance_an_interval (i));
497}
498
486/* Split INTERVAL into two pieces, starting the second piece at 499/* Split INTERVAL into two pieces, starting the second piece at
487 character position OFFSET (counting from 0), relative to INTERVAL. 500 character position OFFSET (counting from 0), relative to INTERVAL.
488 INTERVAL becomes the left-hand piece, and the right-hand piece 501 INTERVAL becomes the left-hand piece, and the right-hand piece
@@ -1204,7 +1217,7 @@ delete_interval (register INTERVAL i)
1204 interval_set_object (parent, owner); 1217 interval_set_object (parent, owner);
1205 1218
1206 if (BUFFERP (owner)) 1219 if (BUFFERP (owner))
1207 BUF_INTERVALS (XBUFFER (owner)) = parent; 1220 buffer_set_intervals (XBUFFER (owner), parent);
1208 else if (STRINGP (owner)) 1221 else if (STRINGP (owner))
1209 string_set_intervals (owner, parent); 1222 string_set_intervals (owner, parent);
1210 else 1223 else
@@ -1306,7 +1319,7 @@ adjust_intervals_for_deletion (struct buffer *buffer,
1306 ptrdiff_t start, ptrdiff_t length) 1319 ptrdiff_t start, ptrdiff_t length)
1307{ 1320{
1308 register ptrdiff_t left_to_delete = length; 1321 register ptrdiff_t left_to_delete = length;
1309 register INTERVAL tree = BUF_INTERVALS (buffer); 1322 register INTERVAL tree = buffer_get_intervals (buffer);
1310 Lisp_Object parent; 1323 Lisp_Object parent;
1311 ptrdiff_t offset; 1324 ptrdiff_t offset;
1312 1325
@@ -1321,7 +1334,7 @@ adjust_intervals_for_deletion (struct buffer *buffer,
1321 1334
1322 if (length == TOTAL_LENGTH (tree)) 1335 if (length == TOTAL_LENGTH (tree))
1323 { 1336 {
1324 BUF_INTERVALS (buffer) = NULL; 1337 buffer_set_intervals (buffer, NULL);
1325 return; 1338 return;
1326 } 1339 }
1327 1340
@@ -1338,10 +1351,10 @@ adjust_intervals_for_deletion (struct buffer *buffer,
1338 { 1351 {
1339 left_to_delete -= interval_deletion_adjustment (tree, start - offset, 1352 left_to_delete -= interval_deletion_adjustment (tree, start - offset,
1340 left_to_delete); 1353 left_to_delete);
1341 tree = BUF_INTERVALS (buffer); 1354 tree = buffer_get_intervals (buffer);
1342 if (left_to_delete == tree->total_length) 1355 if (left_to_delete == tree->total_length)
1343 { 1356 {
1344 BUF_INTERVALS (buffer) = NULL; 1357 buffer_set_intervals (buffer, NULL);
1345 return; 1358 return;
1346 } 1359 }
1347 } 1360 }
@@ -1359,11 +1372,12 @@ adjust_intervals_for_deletion (struct buffer *buffer,
1359void 1372void
1360offset_intervals (struct buffer *buffer, ptrdiff_t start, ptrdiff_t length) 1373offset_intervals (struct buffer *buffer, ptrdiff_t start, ptrdiff_t length)
1361{ 1374{
1362 if (!BUF_INTERVALS (buffer) || length == 0) 1375 if (!buffer_get_intervals (buffer) || length == 0)
1363 return; 1376 return;
1364 1377
1365 if (length > 0) 1378 if (length > 0)
1366 adjust_intervals_for_insertion (BUF_INTERVALS (buffer), start, length); 1379 adjust_intervals_for_insertion (buffer_get_intervals (buffer),
1380 start, length);
1367 else 1381 else
1368 { 1382 {
1369 IF_LINT (if (length < - TYPE_MAXIMUM (ptrdiff_t)) abort ();) 1383 IF_LINT (if (length < - TYPE_MAXIMUM (ptrdiff_t)) abort ();)
@@ -1570,7 +1584,7 @@ graft_intervals_into_buffer (INTERVAL source, ptrdiff_t position,
1570 register INTERVAL tree; 1584 register INTERVAL tree;
1571 ptrdiff_t over_used; 1585 ptrdiff_t over_used;
1572 1586
1573 tree = BUF_INTERVALS (buffer); 1587 tree = buffer_get_intervals (buffer);
1574 1588
1575 /* If the new text has no properties, then with inheritance it 1589 /* If the new text has no properties, then with inheritance it
1576 becomes part of whatever interval it was inserted into. 1590 becomes part of whatever interval it was inserted into.
@@ -1586,31 +1600,34 @@ graft_intervals_into_buffer (INTERVAL source, ptrdiff_t position,
1586 make_number (position + length), 1600 make_number (position + length),
1587 Qnil, buf, 0); 1601 Qnil, buf, 0);
1588 } 1602 }
1589 if (BUF_INTERVALS (buffer)) 1603 /* Shouldn't be necessary. --Stef */
1590 /* Shouldn't be necessary. --Stef */ 1604 buffer_balance_intervals (buffer);
1591 BUF_INTERVALS (buffer) = balance_an_interval (BUF_INTERVALS (buffer));
1592 return; 1605 return;
1593 } 1606 }
1594 1607
1595 eassert (length == TOTAL_LENGTH (source)); 1608 eassert (length == TOTAL_LENGTH (source));
1596 1609
1597 if ((BUF_Z (buffer) - BUF_BEG (buffer)) == length) 1610 if ((BUF_Z (buffer) - BUF_BEG (buffer)) == length)
1598 { /* The inserted text constitutes the whole buffer, so 1611 {
1612 /* The inserted text constitutes the whole buffer, so
1599 simply copy over the interval structure. */ 1613 simply copy over the interval structure. */
1600 Lisp_Object buf; 1614 Lisp_Object buf;
1601 XSETBUFFER (buf, buffer); 1615
1602 BUF_INTERVALS (buffer) = reproduce_tree_obj (source, buf); 1616 XSETBUFFER (buf, buffer);
1603 BUF_INTERVALS (buffer)->position = BUF_BEG (buffer); 1617 buffer_set_intervals (buffer, reproduce_tree_obj (source, buf));
1604 eassert (BUF_INTERVALS (buffer)->up_obj == 1); 1618 buffer_get_intervals (buffer)->position = BUF_BEG (buffer);
1605 return; 1619 eassert (buffer_get_intervals (buffer)->up_obj == 1);
1606 } 1620 return;
1621 }
1607 else if (!tree) 1622 else if (!tree)
1608 { /* Create an interval tree in which to place a copy 1623 {
1624 /* Create an interval tree in which to place a copy
1609 of the intervals of the inserted string. */ 1625 of the intervals of the inserted string. */
1610 Lisp_Object buf; 1626 Lisp_Object buf;
1627
1611 XSETBUFFER (buf, buffer); 1628 XSETBUFFER (buf, buffer);
1612 tree = create_root_interval (buf); 1629 tree = create_root_interval (buf);
1613 } 1630 }
1614 /* Paranoia -- the text has already been added, so 1631 /* Paranoia -- the text has already been added, so
1615 this buffer should be of non-zero length. */ 1632 this buffer should be of non-zero length. */
1616 eassert (TOTAL_LENGTH (tree) > 0); 1633 eassert (TOTAL_LENGTH (tree) > 0);
@@ -1691,9 +1708,7 @@ graft_intervals_into_buffer (INTERVAL source, ptrdiff_t position,
1691 under = next_interval (this); 1708 under = next_interval (this);
1692 } 1709 }
1693 1710
1694 if (BUF_INTERVALS (buffer)) 1711 buffer_balance_intervals (buffer);
1695 BUF_INTERVALS (buffer) = balance_an_interval (BUF_INTERVALS (buffer));
1696 return;
1697} 1712}
1698 1713
1699/* Get the value of property PROP from PLIST, 1714/* Get the value of property PROP from PLIST,
@@ -1860,7 +1875,7 @@ set_point_both (ptrdiff_t charpos, ptrdiff_t bytepos)
1860 1875
1861 /* If we have no text properties and overlays, 1876 /* If we have no text properties and overlays,
1862 then we can do it quickly. */ 1877 then we can do it quickly. */
1863 if (!BUF_INTERVALS (current_buffer) && ! have_overlays) 1878 if (!buffer_get_intervals (current_buffer) && ! have_overlays)
1864 { 1879 {
1865 temp_set_point_both (current_buffer, charpos, bytepos); 1880 temp_set_point_both (current_buffer, charpos, bytepos);
1866 return; 1881 return;
@@ -1869,7 +1884,7 @@ set_point_both (ptrdiff_t charpos, ptrdiff_t bytepos)
1869 /* Set TO to the interval containing the char after CHARPOS, 1884 /* Set TO to the interval containing the char after CHARPOS,
1870 and TOPREV to the interval containing the char before CHARPOS. 1885 and TOPREV to the interval containing the char before CHARPOS.
1871 Either one may be null. They may be equal. */ 1886 Either one may be null. They may be equal. */
1872 to = find_interval (BUF_INTERVALS (current_buffer), charpos); 1887 to = find_interval (buffer_get_intervals (current_buffer), charpos);
1873 if (charpos == BEGV) 1888 if (charpos == BEGV)
1874 toprev = 0; 1889 toprev = 0;
1875 else if (to && to->position == charpos) 1890 else if (to && to->position == charpos)
@@ -1883,7 +1898,7 @@ set_point_both (ptrdiff_t charpos, ptrdiff_t bytepos)
1883 and FROMPREV to the interval containing the char before PT. 1898 and FROMPREV to the interval containing the char before PT.
1884 Either one may be null. They may be equal. */ 1899 Either one may be null. They may be equal. */
1885 /* We could cache this and save time. */ 1900 /* We could cache this and save time. */
1886 from = find_interval (BUF_INTERVALS (current_buffer), buffer_point); 1901 from = find_interval (buffer_get_intervals (current_buffer), buffer_point);
1887 if (buffer_point == BEGV) 1902 if (buffer_point == BEGV)
1888 fromprev = 0; 1903 fromprev = 0;
1889 else if (from && from->position == PT) 1904 else if (from && from->position == PT)
@@ -1989,7 +2004,7 @@ set_point_both (ptrdiff_t charpos, ptrdiff_t bytepos)
1989 /* Set TO to the interval containing the char after CHARPOS, 2004 /* Set TO to the interval containing the char after CHARPOS,
1990 and TOPREV to the interval containing the char before CHARPOS. 2005 and TOPREV to the interval containing the char before CHARPOS.
1991 Either one may be null. They may be equal. */ 2006 Either one may be null. They may be equal. */
1992 to = find_interval (BUF_INTERVALS (current_buffer), charpos); 2007 to = find_interval (buffer_get_intervals (current_buffer), charpos);
1993 if (charpos == BEGV) 2008 if (charpos == BEGV)
1994 toprev = 0; 2009 toprev = 0;
1995 else if (to && to->position == charpos) 2010 else if (to && to->position == charpos)
@@ -2122,9 +2137,9 @@ get_property_and_range (ptrdiff_t pos, Lisp_Object prop, Lisp_Object *val,
2122 INTERVAL i, prev, next; 2137 INTERVAL i, prev, next;
2123 2138
2124 if (NILP (object)) 2139 if (NILP (object))
2125 i = find_interval (BUF_INTERVALS (current_buffer), pos); 2140 i = find_interval (buffer_get_intervals (current_buffer), pos);
2126 else if (BUFFERP (object)) 2141 else if (BUFFERP (object))
2127 i = find_interval (BUF_INTERVALS (XBUFFER (object)), pos); 2142 i = find_interval (buffer_get_intervals (XBUFFER (object)), pos);
2128 else if (STRINGP (object)) 2143 else if (STRINGP (object))
2129 i = find_interval (string_get_intervals (object), pos); 2144 i = find_interval (string_get_intervals (object), pos);
2130 else 2145 else
@@ -2253,7 +2268,7 @@ void
2253copy_intervals_to_string (Lisp_Object string, struct buffer *buffer, 2268copy_intervals_to_string (Lisp_Object string, struct buffer *buffer,
2254 ptrdiff_t position, ptrdiff_t length) 2269 ptrdiff_t position, ptrdiff_t length)
2255{ 2270{
2256 INTERVAL interval_copy = copy_intervals (BUF_INTERVALS (buffer), 2271 INTERVAL interval_copy = copy_intervals (buffer_get_intervals (buffer),
2257 position, length); 2272 position, length);
2258 if (!interval_copy) 2273 if (!interval_copy)
2259 return; 2274 return;
@@ -2418,7 +2433,8 @@ set_intervals_multibyte_1 (INTERVAL i, int multi_flag,
2418void 2433void
2419set_intervals_multibyte (int multi_flag) 2434set_intervals_multibyte (int multi_flag)
2420{ 2435{
2421 if (BUF_INTERVALS (current_buffer)) 2436 INTERVAL i = buffer_get_intervals (current_buffer);
2422 set_intervals_multibyte_1 (BUF_INTERVALS (current_buffer), multi_flag, 2437
2423 BEG, BEG_BYTE, Z, Z_BYTE); 2438 if (i)
2439 set_intervals_multibyte_1 (i, multi_flag, BEG, BEG_BYTE, Z, Z_BYTE);
2424} 2440}
diff --git a/src/textprop.c b/src/textprop.c
index 5366249be89..ac1980fde78 100644
--- a/src/textprop.c
+++ b/src/textprop.c
@@ -143,7 +143,7 @@ validate_interval_range (Lisp_Object object, Lisp_Object *begin, Lisp_Object *en
143 if (!(BUF_BEGV (b) <= XINT (*begin) && XINT (*begin) <= XINT (*end) 143 if (!(BUF_BEGV (b) <= XINT (*begin) && XINT (*begin) <= XINT (*end)
144 && XINT (*end) <= BUF_ZV (b))) 144 && XINT (*end) <= BUF_ZV (b)))
145 args_out_of_range (*begin, *end); 145 args_out_of_range (*begin, *end);
146 i = BUF_INTERVALS (b); 146 i = buffer_get_intervals (b);
147 147
148 /* If there's no text, there are no properties. */ 148 /* If there's no text, there are no properties. */
149 if (BUF_BEGV (b) == BUF_ZV (b)) 149 if (BUF_BEGV (b) == BUF_ZV (b))
@@ -510,7 +510,7 @@ interval_of (ptrdiff_t position, Lisp_Object object)
510 510
511 beg = BUF_BEGV (b); 511 beg = BUF_BEGV (b);
512 end = BUF_ZV (b); 512 end = BUF_ZV (b);
513 i = BUF_INTERVALS (b); 513 i = buffer_get_intervals (b);
514 } 514 }
515 else 515 else
516 { 516 {
@@ -1338,8 +1338,8 @@ set_text_properties_1 (Lisp_Object start, Lisp_Object end, Lisp_Object propertie
1338 else 1338 else
1339 return; 1339 return;
1340 1340
1341 if (i == 0) 1341 if (i == NULL)
1342 i = find_interval (BUF_INTERVALS (XBUFFER (buffer)), s); 1342 i = find_interval (buffer_get_intervals (XBUFFER (buffer)), s);
1343 1343
1344 if (i->position != s) 1344 if (i->position != s)
1345 { 1345 {
@@ -1993,7 +1993,7 @@ void
1993verify_interval_modification (struct buffer *buf, 1993verify_interval_modification (struct buffer *buf,
1994 ptrdiff_t start, ptrdiff_t end) 1994 ptrdiff_t start, ptrdiff_t end)
1995{ 1995{
1996 register INTERVAL intervals = BUF_INTERVALS (buf); 1996 register INTERVAL intervals = buffer_get_intervals (buf);
1997 register INTERVAL i; 1997 register INTERVAL i;
1998 Lisp_Object hooks; 1998 Lisp_Object hooks;
1999 register Lisp_Object prev_mod_hooks; 1999 register Lisp_Object prev_mod_hooks;