summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndreas Politz <politza@hochschule-trier.de>2017-10-09 08:22:43 +0200
committerAndreas Politz <politza@hochschule-trier.de>2017-10-09 08:22:43 +0200
commit8869332684c2302b5ba1ead4568bbc7ba1c0183e (patch)
treea28ca47b5064e0c12b1d9f636ef04948989cf301
parenta38c38c0526894ff05e2317994703c1157d5f909 (diff)
downloademacs-feature/noverlay.tar.gz
Remove redundant checks for the empty overlay treefeature/noverlay
* src/alloc.c (mark_buffer): Remove b->overlays check. * src/buffer.c (copy_overlays): Also. * src/buffer.c (swap_buffer_overlays, overlays_in): Also. (next_overlay_change, previous_overlay_change): Also. (overlay_touches_p, Foverlay_lists): Also. (evaporate_overlays): Also. * src/xdisp.c (load_overlay_strings): Also.
-rw-r--r--src/alloc.c14
-rw-r--r--src/buffer.c63
-rw-r--r--src/xdisp.c82
3 files changed, 62 insertions, 97 deletions
diff --git a/src/alloc.c b/src/alloc.c
index 15a6fc43b72..9f72f914e00 100644
--- a/src/alloc.c
+++ b/src/alloc.c
@@ -6306,15 +6306,11 @@ mark_buffer (struct buffer *buffer)
a special way just before the sweep phase, and after stripping
some of its elements that are not needed any more. */
- if (buffer->overlays)
- {
- struct interval_node *node;
- buffer_overlay_iter_start (buffer, PTRDIFF_MIN, PTRDIFF_MAX, ITREE_ASCENDING);
-
- while ((node = buffer_overlay_iter_next (buffer)))
- mark_overlay (XOVERLAY (node->data));
- buffer_overlay_iter_finish (buffer);
- }
+ struct interval_node *node;
+ buffer_overlay_iter_start (buffer, PTRDIFF_MIN, PTRDIFF_MAX, ITREE_ASCENDING);
+ while ((node = buffer_overlay_iter_next (buffer)))
+ mark_overlay (XOVERLAY (node->data));
+ buffer_overlay_iter_finish (buffer);
/* If this is an indirect buffer, mark its base buffer. */
if (buffer->base_buffer && !VECTOR_MARKED_P (buffer->base_buffer))
diff --git a/src/buffer.c b/src/buffer.c
index 122c60fab39..9ddc9c7e056 100644
--- a/src/buffer.c
+++ b/src/buffer.c
@@ -607,14 +607,9 @@ static void
copy_overlays (struct buffer *from, struct buffer *to)
{
eassert (to && ! to->overlays);
-
struct interval_node *node;
- if (! from->overlays)
- return;
-
buffer_overlay_iter_start (from, PTRDIFF_MIN, PTRDIFF_MAX, ITREE_ASCENDING);
-
while ((node = buffer_overlay_iter_next (from)))
{
Lisp_Object ov = node->data;
@@ -2277,20 +2272,16 @@ swap_buffer_overlays (struct buffer *buffer, struct buffer *other)
{
struct interval_node *node;
- if (buffer->overlays)
- {
- buffer_overlay_iter_start (buffer, PTRDIFF_MIN, PTRDIFF_MAX, ITREE_ASCENDING);
- while ((node = buffer_overlay_iter_next (buffer)))
- XOVERLAY (node->data)->buffer = other;
- buffer_overlay_iter_finish (buffer);
- }
- if (other->overlays)
- {
- buffer_overlay_iter_start (other, PTRDIFF_MIN, PTRDIFF_MAX, ITREE_ASCENDING);
- while ((node = buffer_overlay_iter_next (other)))
- XOVERLAY (node->data)->buffer = buffer;
- buffer_overlay_iter_finish (other);
- }
+ buffer_overlay_iter_start (buffer, PTRDIFF_MIN, PTRDIFF_MAX, ITREE_ASCENDING);
+ while ((node = buffer_overlay_iter_next (buffer)))
+ XOVERLAY (node->data)->buffer = other;
+ buffer_overlay_iter_finish (buffer);
+
+ buffer_overlay_iter_start (other, PTRDIFF_MIN, PTRDIFF_MAX, ITREE_ASCENDING);
+ while ((node = buffer_overlay_iter_next (other)))
+ XOVERLAY (node->data)->buffer = buffer;
+ buffer_overlay_iter_finish (other);
+
/* Swap the interval trees. */
void *tmp = buffer->overlays;
buffer->overlays = other->overlays;
@@ -2837,12 +2828,8 @@ overlays_in (ptrdiff_t beg, ptrdiff_t end, bool extend,
ptrdiff_t len = *len_ptr;
ptrdiff_t next = ZV;
Lisp_Object *vec = *vec_ptr;
-
struct interval_node *node;
- if (! current_buffer->overlays)
- return idx;
-
buffer_overlay_iter_start (current_buffer, beg,
/* Find empty OV at Z ? */
(end >= Z && empty) ? Z + 1 : ZV,
@@ -2904,9 +2891,6 @@ next_overlay_change (ptrdiff_t pos)
ptrdiff_t next = ZV;
struct interval_node *node;
- if (! current_buffer->overlays)
- return next;
-
buffer_overlay_iter_start (current_buffer, pos, ZV, ITREE_ASCENDING);
while ((node = buffer_overlay_iter_next (current_buffer)))
{
@@ -2935,9 +2919,6 @@ previous_overlay_change (ptrdiff_t pos)
struct interval_node *node;
ptrdiff_t prev = BEGV;
- if (! current_buffer->overlays)
- return prev;
-
buffer_overlay_iter_start (current_buffer, BEGV, pos, ITREE_DESCENDING);
while ((node = buffer_overlay_iter_next (current_buffer)))
{
@@ -3023,9 +3004,6 @@ overlay_touches_p (ptrdiff_t pos)
struct interval_node *node;
bool result = false;
- if (! current_buffer->overlays)
- return false;
-
/* We need to find overlays ending in pos, as well as empty ones at
pos. */
buffer_overlay_iter_start (current_buffer,
@@ -3729,16 +3707,13 @@ However, the overlays you get are the real objects that the buffer uses. */)
(void)
{
Lisp_Object overlays = Qnil;
+ struct interval_node *node;
- if (current_buffer->overlays)
- {
- struct interval_node *node;
+ buffer_overlay_iter_start (current_buffer, BEG, Z, ITREE_DESCENDING);
+ while ((node = buffer_overlay_iter_next (current_buffer)))
+ overlays = Fcons (node->data, overlays);
+ buffer_overlay_iter_finish (current_buffer);
- buffer_overlay_iter_start (current_buffer, BEG, Z, ITREE_DESCENDING);
- while ((node = buffer_overlay_iter_next (current_buffer)))
- overlays = Fcons (node->data, overlays);
- buffer_overlay_iter_finish (current_buffer);
- }
return Fcons (overlays, Qnil);
}
@@ -3972,15 +3947,10 @@ call_overlay_mod_hooks (Lisp_Object list, Lisp_Object overlay, bool after,
void
evaporate_overlays (ptrdiff_t pos)
{
- Lisp_Object hit_list;
+ Lisp_Object hit_list = Qnil;
struct interval_node *node;
- if (! current_buffer->overlays)
- return;
-
- hit_list = Qnil;
buffer_overlay_iter_start (current_buffer, pos, pos, ITREE_ASCENDING);
-
while ((node = buffer_overlay_iter_next (current_buffer)))
{
if (node->end == pos
@@ -3988,6 +3958,7 @@ evaporate_overlays (ptrdiff_t pos)
hit_list = Fcons (node->data, hit_list);
}
buffer_overlay_iter_finish (current_buffer);
+
for (; CONSP (hit_list); hit_list = XCDR (hit_list))
Fdelete_overlay (XCAR (hit_list));
}
diff --git a/src/xdisp.c b/src/xdisp.c
index b3b9ecae377..f94643b1f7b 100644
--- a/src/xdisp.c
+++ b/src/xdisp.c
@@ -5790,48 +5790,46 @@ load_overlay_strings (struct it *it, ptrdiff_t charpos)
} \
while (false)
- if (current_buffer->overlays)
- {
- buffer_overlay_iter_start (current_buffer,
- charpos - 1, charpos + 1, ITREE_DESCENDING);
- /* Process overlays. */
- while ((node = buffer_overlay_iter_next (current_buffer)))
- {
- overlay = node->data;
- eassert (OVERLAYP (overlay));
- start = node->begin;
- end = node->end;
-
- /* Skip this overlay if it doesn't start or end at IT's current
- position. */
- if (end != charpos && start != charpos)
- continue;
-
- /* Skip this overlay if it doesn't apply to IT->w. */
- window = Foverlay_get (overlay, Qwindow);
- if (WINDOWP (window) && XWINDOW (window) != it->w)
- continue;
-
- /* If the text ``under'' the overlay is invisible, both before-
- and after-strings from this overlay are visible; start and
- end position are indistinguishable. */
- invisible = Foverlay_get (overlay, Qinvisible);
- invis = TEXT_PROP_MEANS_INVISIBLE (invisible);
-
- /* If overlay has a non-empty before-string, record it. */
- if ((start == charpos || (end == charpos && invis != 0))
- && (str = Foverlay_get (overlay, Qbefore_string), STRINGP (str))
- && SCHARS (str))
- RECORD_OVERLAY_STRING (overlay, str, false);
-
- /* If overlay has a non-empty after-string, record it. */
- if ((end == charpos || (start == charpos && invis != 0))
- && (str = Foverlay_get (overlay, Qafter_string), STRINGP (str))
- && SCHARS (str))
- RECORD_OVERLAY_STRING (overlay, str, true);
- }
- buffer_overlay_iter_finish (current_buffer);
- }
+
+ buffer_overlay_iter_start (current_buffer,
+ charpos - 1, charpos + 1, ITREE_DESCENDING);
+ /* Process overlays. */
+ while ((node = buffer_overlay_iter_next (current_buffer)))
+ {
+ overlay = node->data;
+ eassert (OVERLAYP (overlay));
+ start = node->begin;
+ end = node->end;
+
+ /* Skip this overlay if it doesn't start or end at IT's current
+ position. */
+ if (end != charpos && start != charpos)
+ continue;
+
+ /* Skip this overlay if it doesn't apply to IT->w. */
+ window = Foverlay_get (overlay, Qwindow);
+ if (WINDOWP (window) && XWINDOW (window) != it->w)
+ continue;
+
+ /* If the text ``under'' the overlay is invisible, both before-
+ and after-strings from this overlay are visible; start and
+ end position are indistinguishable. */
+ invisible = Foverlay_get (overlay, Qinvisible);
+ invis = TEXT_PROP_MEANS_INVISIBLE (invisible);
+
+ /* If overlay has a non-empty before-string, record it. */
+ if ((start == charpos || (end == charpos && invis != 0))
+ && (str = Foverlay_get (overlay, Qbefore_string), STRINGP (str))
+ && SCHARS (str))
+ RECORD_OVERLAY_STRING (overlay, str, false);
+
+ /* If overlay has a non-empty after-string, record it. */
+ if ((end == charpos || (start == charpos && invis != 0))
+ && (str = Foverlay_get (overlay, Qafter_string), STRINGP (str))
+ && SCHARS (str))
+ RECORD_OVERLAY_STRING (overlay, str, true);
+ }
+ buffer_overlay_iter_finish (current_buffer);
#undef RECORD_OVERLAY_STRING