Commit 8ca30920 authored by Dmitry Antipov's avatar Dmitry Antipov

* search.c (scan_buffer): Calculate end byte position just once.

(scan_newline): Do not recalculate start_byte.
(search_command): Use eassert.
* syntax.c (struct lisp_parse_state): New member location_byte.
(scan_sexps_forward): Record from_byte and avoid redundant
character to byte position calculation ...
(Fparse_partial_sexp): ... here.  Break too long line.
parent 6130b96a
2013-02-08 Dmitry Antipov <dmantipov@yandex.ru>
* search.c (scan_buffer): Calculate end byte position just once.
(scan_newline): Do not recalculate start_byte.
(search_command): Use eassert.
* syntax.c (struct lisp_parse_state): New member location_byte.
(scan_sexps_forward): Record from_byte and avoid redundant
character to byte position calculation ...
(Fparse_partial_sexp): ... here. Break too long line.
2013-02-08 Dmitry Antipov <dmantipov@yandex.ru> 2013-02-08 Dmitry Antipov <dmantipov@yandex.ru>
* lisp.h (make_uninit_vector): New function. * lisp.h (make_uninit_vector): New function.
......
...@@ -644,18 +644,23 @@ scan_buffer (int target, ptrdiff_t start, ptrdiff_t end, ...@@ -644,18 +644,23 @@ scan_buffer (int target, ptrdiff_t start, ptrdiff_t end,
ptrdiff_t count, ptrdiff_t *shortage, bool allow_quit) ptrdiff_t count, ptrdiff_t *shortage, bool allow_quit)
{ {
struct region_cache *newline_cache; struct region_cache *newline_cache;
ptrdiff_t end_byte = -1;
int direction; int direction;
if (count > 0) if (count > 0)
{ {
direction = 1; direction = 1;
if (! end) end = ZV; if (!end)
end = ZV, end_byte = ZV_BYTE;
} }
else else
{ {
direction = -1; direction = -1;
if (! end) end = BEGV; if (!end)
end = BEGV, end_byte = BEGV_BYTE;
} }
if (end_byte == -1)
end_byte = CHAR_TO_BYTE (end);
newline_cache_on_off (current_buffer); newline_cache_on_off (current_buffer);
newline_cache = current_buffer->newline_cache; newline_cache = current_buffer->newline_cache;
...@@ -673,7 +678,7 @@ scan_buffer (int target, ptrdiff_t start, ptrdiff_t end, ...@@ -673,7 +678,7 @@ scan_buffer (int target, ptrdiff_t start, ptrdiff_t end,
the position of the last character before the next such the position of the last character before the next such
obstacle --- the last character the dumb search loop should obstacle --- the last character the dumb search loop should
examine. */ examine. */
ptrdiff_t ceiling_byte = CHAR_TO_BYTE (end) - 1; ptrdiff_t ceiling_byte = end_byte - 1;
ptrdiff_t start_byte; ptrdiff_t start_byte;
ptrdiff_t tem; ptrdiff_t tem;
...@@ -750,7 +755,7 @@ scan_buffer (int target, ptrdiff_t start, ptrdiff_t end, ...@@ -750,7 +755,7 @@ scan_buffer (int target, ptrdiff_t start, ptrdiff_t end,
while (start > end) while (start > end)
{ {
/* The last character to check before the next obstacle. */ /* The last character to check before the next obstacle. */
ptrdiff_t ceiling_byte = CHAR_TO_BYTE (end); ptrdiff_t ceiling_byte = end_byte;
ptrdiff_t start_byte; ptrdiff_t start_byte;
ptrdiff_t tem; ptrdiff_t tem;
...@@ -861,8 +866,6 @@ scan_newline (ptrdiff_t start, ptrdiff_t start_byte, ...@@ -861,8 +866,6 @@ scan_newline (ptrdiff_t start, ptrdiff_t start_byte,
if (allow_quit) if (allow_quit)
immediate_quit++; immediate_quit++;
start_byte = CHAR_TO_BYTE (start);
if (count > 0) if (count > 0)
{ {
while (start_byte < limit_byte) while (start_byte < limit_byte)
...@@ -1016,8 +1019,7 @@ search_command (Lisp_Object string, Lisp_Object bound, Lisp_Object noerror, ...@@ -1016,8 +1019,7 @@ search_command (Lisp_Object string, Lisp_Object bound, Lisp_Object noerror,
if (!EQ (noerror, Qt)) if (!EQ (noerror, Qt))
{ {
if (lim < BEGV || lim > ZV) eassert (BEGV <= lim && lim <= ZV);
emacs_abort ();
SET_PT_BOTH (lim, lim_byte); SET_PT_BOTH (lim, lim_byte);
return Qnil; return Qnil;
#if 0 /* This would be clean, but maybe programs depend on #if 0 /* This would be clean, but maybe programs depend on
...@@ -1029,9 +1031,7 @@ search_command (Lisp_Object string, Lisp_Object bound, Lisp_Object noerror, ...@@ -1029,9 +1031,7 @@ search_command (Lisp_Object string, Lisp_Object bound, Lisp_Object noerror,
return Qnil; return Qnil;
} }
if (np < BEGV || np > ZV) eassert (BEGV <= np && np <= ZV);
emacs_abort ();
SET_PT (np); SET_PT (np);
return make_number (np); return make_number (np);
......
...@@ -121,6 +121,7 @@ struct lisp_parse_state ...@@ -121,6 +121,7 @@ struct lisp_parse_state
/* Char number of start of containing expression */ /* Char number of start of containing expression */
ptrdiff_t prevlevelstart; ptrdiff_t prevlevelstart;
ptrdiff_t location; /* Char number at which parsing stopped. */ ptrdiff_t location; /* Char number at which parsing stopped. */
ptrdiff_t location_byte; /* Corresponding byte position. */
ptrdiff_t comstr_start; /* Position of last comment/string starter. */ ptrdiff_t comstr_start; /* Position of last comment/string starter. */
Lisp_Object levelstarts; /* Char numbers of starts-of-expression Lisp_Object levelstarts; /* Char numbers of starts-of-expression
of levels (starting from outermost). */ of levels (starting from outermost). */
...@@ -3288,6 +3289,7 @@ do { prev_from = from; \ ...@@ -3288,6 +3289,7 @@ do { prev_from = from; \
state.prevlevelstart state.prevlevelstart
= (curlevel == levelstart) ? -1 : (curlevel - 1)->last; = (curlevel == levelstart) ? -1 : (curlevel - 1)->last;
state.location = from; state.location = from;
state.location_byte = from_byte;
state.levelstarts = Qnil; state.levelstarts = Qnil;
while (curlevel > levelstart) while (curlevel > levelstart)
state.levelstarts = Fcons (make_number ((--curlevel)->last), state.levelstarts = Fcons (make_number ((--curlevel)->last),
...@@ -3327,7 +3329,8 @@ Fifth arg OLDSTATE is a list like what this function returns. ...@@ -3327,7 +3329,8 @@ Fifth arg OLDSTATE is a list like what this function returns.
Sixth arg COMMENTSTOP non-nil means stop at the start of a comment. Sixth arg COMMENTSTOP non-nil means stop at the start of a comment.
If it is symbol `syntax-table', stop after the start of a comment or a If it is symbol `syntax-table', stop after the start of a comment or a
string, or after end of a comment or a string. */) string, or after end of a comment or a string. */)
(Lisp_Object from, Lisp_Object to, Lisp_Object targetdepth, Lisp_Object stopbefore, Lisp_Object oldstate, Lisp_Object commentstop) (Lisp_Object from, Lisp_Object to, Lisp_Object targetdepth,
Lisp_Object stopbefore, Lisp_Object oldstate, Lisp_Object commentstop)
{ {
struct lisp_parse_state state; struct lisp_parse_state state;
EMACS_INT target; EMACS_INT target;
...@@ -3347,7 +3350,7 @@ Sixth arg COMMENTSTOP non-nil means stop at the start of a comment. ...@@ -3347,7 +3350,7 @@ Sixth arg COMMENTSTOP non-nil means stop at the start of a comment.
(NILP (commentstop) (NILP (commentstop)
? 0 : (EQ (commentstop, Qsyntax_table) ? -1 : 1))); ? 0 : (EQ (commentstop, Qsyntax_table) ? -1 : 1)));
SET_PT (state.location); SET_PT_BOTH (state.location, state.location_byte);
return Fcons (make_number (state.depth), return Fcons (make_number (state.depth),
Fcons (state.prevlevelstart < 0 Fcons (state.prevlevelstart < 0
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment