From: Dmitry Antipov Date: Mon, 11 Feb 2013 10:21:52 +0000 (+0400) Subject: * marker.c (set_marker_internal): If desired position is passed X-Git-Tag: emacs-24.3.90~173^2~7^2~91 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=f74de3451c2cb3033f6d17f9c479150d00e4caa8;p=emacs.git * marker.c (set_marker_internal): If desired position is passed as a marker, avoid call to buf_charpos_to_bytepos. * window.c (Fset_window_point): Omit redundant type checking. (Fset_window_start): Likewise. Format comment. (window_scroll_pixel_based): Use set_marker_restricted_both with character and byte positions obtained from an iterator. (Fset_window_configuration): Use set_marker_restricted_both. * xdisp.c (message_dolog): Likewise. --- diff --git a/src/ChangeLog b/src/ChangeLog index 9d8540075de..163f2e164f4 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,14 @@ +2013-02-11 Dmitry Antipov + + * marker.c (set_marker_internal): If desired position is passed + as a marker, avoid call to buf_charpos_to_bytepos. + * window.c (Fset_window_point): Omit redundant type checking. + (Fset_window_start): Likewise. Format comment. + (window_scroll_pixel_based): Use set_marker_restricted_both + with character and byte positions obtained from an iterator. + (Fset_window_configuration): Use set_marker_restricted_both. + * xdisp.c (message_dolog): Likewise. + 2013-02-10 Eli Zaretskii * xdisp.c (move_it_vertically_backward, move_it_by_lines): When diff --git a/src/marker.c b/src/marker.c index a03a0b104ca..0d992c0abfa 100644 --- a/src/marker.c +++ b/src/marker.c @@ -499,11 +499,29 @@ set_marker_internal (Lisp_Object marker, Lisp_Object position, { register ptrdiff_t charpos, bytepos; - CHECK_NUMBER_COERCE_MARKER (position); - charpos = clip_to_bounds (restricted ? BUF_BEGV (b) : BUF_BEG (b), - XINT (position), - restricted ? BUF_ZV (b) : BUF_Z (b)); - bytepos = buf_charpos_to_bytepos (b, charpos); + /* Do not use CHECK_NUMBER_COERCE_MARKER because we + don't want to call buf_charpos_to_bytepos if POSTION + is a marker and so we know the bytepos already. */ + if (INTEGERP (position)) + charpos = XINT (position), bytepos = -1; + else if (MARKERP (position)) + { + charpos = XMARKER (position)->charpos; + bytepos = XMARKER (position)->bytepos; + } + else + wrong_type_argument (Qinteger_or_marker_p, position); + + charpos = clip_to_bounds + (restricted ? BUF_BEGV (b) : BUF_BEG (b), charpos, + restricted ? BUF_ZV (b) : BUF_Z (b)); + if (bytepos == -1) + bytepos = buf_charpos_to_bytepos (b, charpos); + else + bytepos = clip_to_bounds + (restricted ? BUF_BEGV_BYTE (b) : BUF_BEG_BYTE (b), + bytepos, restricted ? BUF_ZV_BYTE (b) : BUF_Z_BYTE (b)); + attach_marker (m, b, charpos, bytepos); } return marker; diff --git a/src/window.c b/src/window.c index cc115c094f0..ea1dd93711c 100644 --- a/src/window.c +++ b/src/window.c @@ -1544,7 +1544,7 @@ Return POS. */) { register struct window *w = decode_live_window (window); - CHECK_NUMBER_COERCE_MARKER (pos); + /* Type of POS is checked by Fgoto_char or set_marker_restricted ... */ if (w == XWINDOW (selected_window)) { @@ -1554,6 +1554,8 @@ Return POS. */) { struct buffer *old_buffer = current_buffer; + /* ... but here we want to catch type error before buffer change. */ + CHECK_NUMBER_COERCE_MARKER (pos); set_buffer_internal (XBUFFER (w->buffer)); Fgoto_char (pos); set_buffer_internal (old_buffer); @@ -1579,9 +1581,8 @@ overriding motion of point in order to display at this exact start. */) { register struct window *w = decode_live_window (window); - CHECK_NUMBER_COERCE_MARKER (pos); set_marker_restricted (w->start, pos, w->buffer); - /* this is not right, but much easier than doing what is right. */ + /* This is not right, but much easier than doing what is right. */ w->start_at_line_beg = 0; if (NILP (noforce)) w->force_start = 1; @@ -4615,8 +4616,8 @@ window_scroll_pixel_based (Lisp_Object window, int n, int whole, int noerror) } /* Set the window start, and set up the window for redisplay. */ - set_marker_restricted (w->start, make_number (pos), - w->buffer); + set_marker_restricted_both (w->start, w->buffer, IT_CHARPOS (it), + IT_BYTEPOS (it)); bytepos = marker_byte_position (w->start); w->start_at_line_beg = (pos == BEGV || FETCH_BYTE (bytepos - 1) == '\n'); w->update_mode_line = 1; @@ -5795,8 +5796,7 @@ the return value is nil. Otherwise the value is t. */) { /* Set window markers at start of visible range. */ if (XMARKER (w->start)->buffer == 0) - set_marker_restricted (w->start, make_number (0), - w->buffer); + set_marker_restricted_both (w->start, w->buffer, 0, 0); if (XMARKER (w->pointm)->buffer == 0) set_marker_restricted_both (w->pointm, w->buffer, @@ -5814,10 +5814,8 @@ the return value is nil. Otherwise the value is t. */) wset_buffer (w, other_buffer_safely (Fcurrent_buffer ())); /* This will set the markers to beginning of visible range. */ - set_marker_restricted (w->start, - make_number (0), w->buffer); - set_marker_restricted (w->pointm, - make_number (0), w->buffer); + set_marker_restricted_both (w->start, w->buffer, 0, 0); + set_marker_restricted_both (w->pointm, w->buffer, 0, 0); w->start_at_line_beg = 1; if (!NILP (w->dedicated)) /* Record this window as dead. */ diff --git a/src/xdisp.c b/src/xdisp.c index 8314e91ad7f..25c09fe40bd 100644 --- a/src/xdisp.c +++ b/src/xdisp.c @@ -9396,11 +9396,11 @@ message_dolog (const char *m, ptrdiff_t nbytes, int nlflag, int multibyte) bset_undo_list (current_buffer, Qt); oldpoint = message_dolog_marker1; - set_marker_restricted (oldpoint, make_number (PT), Qnil); + set_marker_restricted_both (oldpoint, Qnil, PT, PT_BYTE); oldbegv = message_dolog_marker2; - set_marker_restricted (oldbegv, make_number (BEGV), Qnil); + set_marker_restricted_both (oldbegv, Qnil, BEGV, BEGV_BYTE); oldzv = message_dolog_marker3; - set_marker_restricted (oldzv, make_number (ZV), Qnil); + set_marker_restricted_both (oldzv, Qnil, ZV, ZV_BYTE); GCPRO1 (old_deactivate_mark); if (PT == Z)