[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Emacs-diffs] /srv/bzr/emacs/trunk r111280: Avoid calls to CHAR_TO_BYTE
From: |
Dmitry Antipov |
Subject: |
[Emacs-diffs] /srv/bzr/emacs/trunk r111280: Avoid calls to CHAR_TO_BYTE if byte position is known. |
Date: |
Thu, 20 Dec 2012 20:09:05 +0400 |
User-agent: |
Bazaar (2.5.0) |
------------------------------------------------------------
revno: 111280
committer: Dmitry Antipov <address@hidden>
branch nick: trunk
timestamp: Thu 2012-12-20 20:09:05 +0400
message:
Avoid calls to CHAR_TO_BYTE if byte position is known.
* editfns.c (make_buffer_string_both): Use move_gap_both.
(Fbuffer_string): Use make_buffer_string_both.
* marker.c (buf_charpos_to_bytepos): Convert to eassert.
Adjust comment.
(buf_bytepos_to_charpos): Likewise.
(charpos_to_bytepos): Remove.
* fileio.c (Finsert_file_contents): Use move_gap_both.
* search.c (Freplace_match): Likewise.
* process.c (process_send_region): Likewise. Use convenient
names for byte positions.
* lisp.h (charpos_to_bytepos): Remove prototype.
* indent.c (scan_for_column): Use CHAR_TO_BYTE.
* insdel.c (move_gap): Likewise.
modified:
src/ChangeLog
src/editfns.c
src/fileio.c
src/indent.c
src/insdel.c
src/lisp.h
src/marker.c
src/process.c
src/search.c
=== modified file 'src/ChangeLog'
--- a/src/ChangeLog 2012-12-20 14:57:40 +0000
+++ b/src/ChangeLog 2012-12-20 16:09:05 +0000
@@ -1,3 +1,20 @@
+2012-12-20 Dmitry Antipov <address@hidden>
+
+ Avoid calls to CHAR_TO_BYTE if byte position is known.
+ * editfns.c (make_buffer_string_both): Use move_gap_both.
+ (Fbuffer_string): Use make_buffer_string_both.
+ * marker.c (buf_charpos_to_bytepos): Convert to eassert.
+ Adjust comment.
+ (buf_bytepos_to_charpos): Likewise.
+ (charpos_to_bytepos): Remove.
+ * fileio.c (Finsert_file_contents): Use move_gap_both.
+ * search.c (Freplace_match): Likewise.
+ * process.c (process_send_region): Likewise. Use convenient
+ names for byte positions.
+ * lisp.h (charpos_to_bytepos): Remove prototype.
+ * indent.c (scan_for_column): Use CHAR_TO_BYTE.
+ * insdel.c (move_gap): Likewise.
+
2012-12-20 Paul Eggert <address@hidden>
* xdisp.c (redisplay_internal): Remove now-unused local.
=== modified file 'src/editfns.c'
--- a/src/editfns.c 2012-12-14 19:43:12 +0000
+++ b/src/editfns.c 2012-12-20 16:09:05 +0000
@@ -2501,7 +2501,7 @@
Lisp_Object result, tem, tem1;
if (start < GPT && GPT < end)
- move_gap (start);
+ move_gap_both (start, start_byte);
if (! NILP (BVAR (current_buffer, enable_multibyte_characters)))
result = make_uninit_multibyte_string (end - start, end_byte - start_byte);
@@ -2599,7 +2599,7 @@
of the buffer. */)
(void)
{
- return make_buffer_string (BEGV, ZV, 1);
+ return make_buffer_string_both (BEGV, BEGV_BYTE, ZV, ZV_BYTE, 1);
}
DEFUN ("insert-buffer-substring", Finsert_buffer_substring,
Sinsert_buffer_substring,
=== modified file 'src/fileio.c'
--- a/src/fileio.c 2012-12-17 19:14:34 +0000
+++ b/src/fileio.c 2012-12-20 16:09:05 +0000
@@ -4131,7 +4131,7 @@
prepare_to_modify_buffer (GPT, GPT, NULL);
}
- move_gap (PT);
+ move_gap_both (PT, PT_BYTE);
if (GAP_SIZE < total)
make_gap (total - GAP_SIZE);
=== modified file 'src/indent.c'
--- a/src/indent.c 2012-12-11 06:08:53 +0000
+++ b/src/indent.c 2012-12-20 16:09:05 +0000
@@ -571,7 +571,8 @@
col += width;
if (endp > scan) /* Avoid infinite loops with 0-width overlays. */
{
- scan = endp; scan_byte = charpos_to_bytepos (scan);
+ scan = endp;
+ scan_byte = CHAR_TO_BYTE (scan);
continue;
}
}
=== modified file 'src/insdel.c'
--- a/src/insdel.c 2012-12-11 09:51:12 +0000
+++ b/src/insdel.c 2012-12-20 16:09:05 +0000
@@ -90,7 +90,7 @@
void
move_gap (ptrdiff_t charpos)
{
- move_gap_both (charpos, charpos_to_bytepos (charpos));
+ move_gap_both (charpos, CHAR_TO_BYTE (charpos));
}
/* Move gap to byte position BYTEPOS, which is also char position CHARPOS.
=== modified file 'src/lisp.h'
--- a/src/lisp.h 2012-12-15 15:33:43 +0000
+++ b/src/lisp.h 2012-12-20 16:09:05 +0000
@@ -3176,7 +3176,6 @@
extern ptrdiff_t marker_position (Lisp_Object);
extern ptrdiff_t marker_byte_position (Lisp_Object);
extern void clear_charpos_cache (struct buffer *);
-extern ptrdiff_t charpos_to_bytepos (ptrdiff_t);
extern ptrdiff_t buf_charpos_to_bytepos (struct buffer *, ptrdiff_t);
extern ptrdiff_t buf_bytepos_to_charpos (struct buffer *, ptrdiff_t);
extern void unchain_marker (struct Lisp_Marker *marker);
=== modified file 'src/marker.c'
--- a/src/marker.c 2012-10-11 16:23:37 +0000
+++ b/src/marker.c 2012-12-20 16:09:05 +0000
@@ -82,9 +82,7 @@
and everywhere there is a marker. So we find the one of these places
that is closest to the specified position, and scan from there. */
-/* charpos_to_bytepos returns the byte position corresponding to CHARPOS. */
-
-/* This macro is a subroutine of charpos_to_bytepos.
+/* This macro is a subroutine of buf_charpos_to_bytepos.
Note that it is desirable that BYTEPOS is not evaluated
except when we really want its value. */
@@ -128,11 +126,7 @@
} \
}
-ptrdiff_t
-charpos_to_bytepos (ptrdiff_t charpos)
-{
- return buf_charpos_to_bytepos (current_buffer, charpos);
-}
+/* Return the byte position corresponding to CHARPOS in B. */
ptrdiff_t
buf_charpos_to_bytepos (struct buffer *b, ptrdiff_t charpos)
@@ -141,8 +135,7 @@
ptrdiff_t best_above, best_above_byte;
ptrdiff_t best_below, best_below_byte;
- if (charpos < BUF_BEG (b) || charpos > BUF_Z (b))
- emacs_abort ();
+ eassert (BUF_BEG (b) <= charpos && charpos <= BUF_Z (b));
best_above = BUF_Z (b);
best_above_byte = BUF_Z_BYTE (b);
@@ -242,9 +235,6 @@
#undef CONSIDER
-/* buf_bytepos_to_charpos returns the char position corresponding to
- BYTEPOS. */
-
/* This macro is a subroutine of buf_bytepos_to_charpos.
It is used when BYTEPOS is actually the byte position. */
@@ -288,6 +278,8 @@
} \
}
+/* Return the character position corresponding to BYTEPOS in B. */
+
ptrdiff_t
buf_bytepos_to_charpos (struct buffer *b, ptrdiff_t bytepos)
{
@@ -295,8 +287,7 @@
ptrdiff_t best_above, best_above_byte;
ptrdiff_t best_below, best_below_byte;
- if (bytepos < BUF_BEG_BYTE (b) || bytepos > BUF_Z_BYTE (b))
- emacs_abort ();
+ eassert (BUF_BEG_BYTE (b) <= bytepos && bytepos <= BUF_Z_BYTE (b));
best_above = BUF_Z (b);
best_above_byte = BUF_Z_BYTE (b);
=== modified file 'src/process.c'
--- a/src/process.c 2012-12-17 17:51:25 +0000
+++ b/src/process.c 2012-12-20 16:09:05 +0000
@@ -5556,19 +5556,19 @@
Output from processes can arrive in between bunches. */)
(Lisp_Object process, Lisp_Object start, Lisp_Object end)
{
- Lisp_Object proc;
- ptrdiff_t start1, end1;
+ Lisp_Object proc = get_process (process);
+ ptrdiff_t start_byte, end_byte;
- proc = get_process (process);
validate_region (&start, &end);
+ start_byte = CHAR_TO_BYTE (XINT (start));
+ end_byte = CHAR_TO_BYTE (XINT (end));
+
if (XINT (start) < GPT && XINT (end) > GPT)
- move_gap (XINT (start));
+ move_gap_both (XINT (start), start_byte);
- start1 = CHAR_TO_BYTE (XINT (start));
- end1 = CHAR_TO_BYTE (XINT (end));
- send_process (proc, (char *) BYTE_POS_ADDR (start1), end1 - start1,
- Fcurrent_buffer ());
+ send_process (proc, (char *) BYTE_POS_ADDR (start_byte),
+ end_byte - start_byte, Fcurrent_buffer ());
return Qnil;
}
=== modified file 'src/search.c'
--- a/src/search.c 2012-12-11 15:30:45 +0000
+++ b/src/search.c 2012-12-20 16:09:05 +0000
@@ -2599,7 +2599,7 @@
ptrdiff_t begbyte = CHAR_TO_BYTE (search_regs.start[idx]);
add_len = CHAR_TO_BYTE (search_regs.end[idx]) - begbyte;
if (search_regs.start[idx] < GPT && GPT < search_regs.end[idx])
- move_gap (search_regs.start[idx]);
+ move_gap_both (search_regs.start[idx], begbyte);
add_stuff = BYTE_POS_ADDR (begbyte);
}
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Emacs-diffs] /srv/bzr/emacs/trunk r111280: Avoid calls to CHAR_TO_BYTE if byte position is known.,
Dmitry Antipov <=