diff options
| author | Dmitry Antipov | 2012-07-06 09:07:44 +0400 |
|---|---|---|
| committer | Dmitry Antipov | 2012-07-06 09:07:44 +0400 |
| commit | 657924ff58fc22a6e57dc8366a20dadf97324c63 (patch) | |
| tree | 94e256617a34f005119bcf7481bbbaa41c19a63f /src/alloc.c | |
| parent | 6edc3d285d0495d69888018758371abfa4752327 (diff) | |
| download | emacs-657924ff58fc22a6e57dc8366a20dadf97324c63.tar.gz emacs-657924ff58fc22a6e57dc8366a20dadf97324c63.zip | |
Introduce fast path for the widely used marker operation.
* alloc.c (build_marker): New function.
* lisp.h (build_marker): New prototype.
* buffer.c (clone_per_buffer_values, Fmake_indirect_buffer): Use it.
* composite.c (autocmp_chars): Likewise.
* editfns.c (buildmark): Remove.
(Fpoint_marker, Fpoint_min_marker, Fpoint_max_marker)
(save_restriction_save): Use build_marker.
* marker.c (buf_charpos_to_bytepos, buf_bytepos_to_charpos): Likewise.
* window.c (save_window_save): Likewise.
Diffstat (limited to 'src/alloc.c')
| -rw-r--r-- | src/alloc.c | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/src/alloc.c b/src/alloc.c index 695d71c6c94..88f96c41a15 100644 --- a/src/alloc.c +++ b/src/alloc.c | |||
| @@ -3641,6 +3641,33 @@ DEFUN ("make-marker", Fmake_marker, Smake_marker, 0, 0, 0, | |||
| 3641 | return val; | 3641 | return val; |
| 3642 | } | 3642 | } |
| 3643 | 3643 | ||
| 3644 | /* Return a newly allocated marker which points into BUF | ||
| 3645 | at character position CHARPOS and byte position BYTEPOS. */ | ||
| 3646 | |||
| 3647 | Lisp_Object | ||
| 3648 | build_marker (struct buffer *buf, ptrdiff_t charpos, ptrdiff_t bytepos) | ||
| 3649 | { | ||
| 3650 | Lisp_Object obj; | ||
| 3651 | struct Lisp_Marker *m; | ||
| 3652 | |||
| 3653 | /* No dead buffers here. */ | ||
| 3654 | eassert (!NILP (BVAR (buf, name))); | ||
| 3655 | |||
| 3656 | /* Every character is at least one byte. */ | ||
| 3657 | eassert (charpos <= bytepos); | ||
| 3658 | |||
| 3659 | obj = allocate_misc (); | ||
| 3660 | XMISCTYPE (obj) = Lisp_Misc_Marker; | ||
| 3661 | m = XMARKER (obj); | ||
| 3662 | m->buffer = buf; | ||
| 3663 | m->charpos = charpos; | ||
| 3664 | m->bytepos = bytepos; | ||
| 3665 | m->insertion_type = 0; | ||
| 3666 | m->next = BUF_MARKERS (buf); | ||
| 3667 | BUF_MARKERS (buf) = m; | ||
| 3668 | return obj; | ||
| 3669 | } | ||
| 3670 | |||
| 3644 | /* Put MARKER back on the free list after using it temporarily. */ | 3671 | /* Put MARKER back on the free list after using it temporarily. */ |
| 3645 | 3672 | ||
| 3646 | void | 3673 | void |