[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Emacs-diffs] /srv/bzr/emacs/trunk r108902: * buffer.c (unchain_overlay)
From: |
Dmitry Antipov |
Subject: |
[Emacs-diffs] /srv/bzr/emacs/trunk r108902: * buffer.c (unchain_overlay): Simplify. Add comment. |
Date: |
Fri, 06 Jul 2012 11:34:37 +0400 |
User-agent: |
Bazaar (2.5.0) |
------------------------------------------------------------
revno: 108902
committer: Dmitry Antipov <address@hidden>
branch nick: trunk
timestamp: Fri 2012-07-06 11:34:37 +0400
message:
* buffer.c (unchain_overlay): Simplify. Add comment.
* marker.c (unchain_marker): Simplify. Fix comments.
modified:
src/ChangeLog
src/buffer.c
src/marker.c
=== modified file 'src/ChangeLog'
--- a/src/ChangeLog 2012-07-06 05:07:44 +0000
+++ b/src/ChangeLog 2012-07-06 07:34:37 +0000
@@ -1,5 +1,10 @@
2012-07-06 Dmitry Antipov <address@hidden>
+ * buffer.c (unchain_overlay): Simplify. Add comment.
+ * marker.c (unchain_marker): Simplify. Fix comments.
+
+2012-07-06 Dmitry Antipov <address@hidden>
+
Introduce fast path for the widely used marker operation.
* alloc.c (build_marker): New function.
* lisp.h (build_marker): New prototype.
=== modified file 'src/buffer.c'
--- a/src/buffer.c 2012-07-06 05:07:44 +0000
+++ b/src/buffer.c 2012-07-06 07:34:37 +0000
@@ -3672,18 +3672,17 @@
++BUF_OVERLAY_MODIFF (buf);
}
-
+/* Remove OVERLAY from LIST. */
+
static struct Lisp_Overlay *
unchain_overlay (struct Lisp_Overlay *list, struct Lisp_Overlay *overlay)
{
- struct Lisp_Overlay *tmp, *prev;
- for (tmp = list, prev = NULL; tmp; prev = tmp, tmp = tmp->next)
- if (tmp == overlay)
+ register struct Lisp_Overlay *tail, **prev = &list;
+
+ for (tail = list; tail; prev = &tail->next, tail = *prev)
+ if (tail == overlay)
{
- if (prev)
- prev->next = tmp->next;
- else
- list = tmp->next;
+ *prev = overlay->next;
overlay->next = NULL;
break;
}
=== modified file 'src/marker.c'
--- a/src/marker.c 2012-07-06 05:07:44 +0000
+++ b/src/marker.c 2012-07-06 07:34:37 +0000
@@ -672,59 +672,47 @@
return marker;
}
-/* Remove MARKER from the chain of whatever buffer it is in.
- Leave it "in no buffer".
-
- This is called during garbage collection,
- so we must be careful to ignore and preserve mark bits,
- including those in chain fields of markers. */
+/* Remove MARKER from the chain of whatever buffer it is in,
+ leaving it points to nowhere. This is called during garbage
+ collection, so we must be careful to ignore and preserve
+ mark bits, including those in chain fields of markers. */
void
unchain_marker (register struct Lisp_Marker *marker)
{
- register struct Lisp_Marker *tail, *prev, *next;
- register struct buffer *b;
-
- b = marker->buffer;
- if (b == 0)
- return;
-
- if (EQ (BVAR (b, name), Qnil))
- abort ();
-
- marker->buffer = 0;
-
- tail = BUF_MARKERS (b);
- prev = NULL;
- while (tail)
+ register struct buffer *b = marker->buffer;
+
+ if (b)
{
- next = tail->next;
-
- if (marker == tail)
- {
- if (!prev)
- {
- BUF_MARKERS (b) = next;
- /* Deleting first marker from the buffer's chain. Crash
- if new first marker in chain does not say it belongs
- to the same buffer, or at least that they have the same
- base buffer. */
- if (next && b->text != next->buffer->text)
- abort ();
- }
- else
- prev->next = next;
- /* We have removed the marker from the chain;
- no need to scan the rest of the chain. */
- return;
- }
- else
- prev = tail;
- tail = next;
+ register struct Lisp_Marker *tail, **prev;
+
+ /* No dead buffers here. */
+ eassert (!NILP (BVAR (b, name)));
+
+ marker->buffer = NULL;
+ prev = &BUF_MARKERS (b);
+
+ for (tail = BUF_MARKERS (b); tail; prev = &tail->next, tail = *prev)
+ if (marker == tail)
+ {
+ if (*prev == BUF_MARKERS (b))
+ {
+ /* Deleting first marker from the buffer's chain. Crash
+ if new first marker in chain does not say it belongs
+ to the same buffer, or at least that they have the same
+ base buffer. */
+ if (tail->next && b->text != tail->next->buffer->text)
+ abort ();
+ }
+ *prev = tail->next;
+ /* We have removed the marker from the chain;
+ no need to scan the rest of the chain. */
+ break;
+ }
+
+ /* Error if marker was not in it's chain. */
+ eassert (tail != NULL);
}
-
- /* Marker was not in its chain. */
- abort ();
}
/* Return the char position of marker MARKER, as a C integer. */
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Emacs-diffs] /srv/bzr/emacs/trunk r108902: * buffer.c (unchain_overlay): Simplify. Add comment.,
Dmitry Antipov <=