diff options
| author | Dmitry Antipov | 2013-02-08 18:44:53 +0400 |
|---|---|---|
| committer | Dmitry Antipov | 2013-02-08 18:44:53 +0400 |
| commit | 8ca30920525154d5eef67899b04dde77f4176169 (patch) | |
| tree | 21370d2a80e1698b9fcd835527ee3dda5f8324fa /src | |
| parent | 6130b96ae7ed9632e7623fb86eac695edc401098 (diff) | |
| download | emacs-8ca30920525154d5eef67899b04dde77f4176169.tar.gz emacs-8ca30920525154d5eef67899b04dde77f4176169.zip | |
* 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.
Diffstat (limited to 'src')
| -rw-r--r-- | src/ChangeLog | 10 | ||||
| -rw-r--r-- | src/search.c | 22 | ||||
| -rw-r--r-- | src/syntax.c | 7 |
3 files changed, 26 insertions, 13 deletions
diff --git a/src/ChangeLog b/src/ChangeLog index 073227281f0..420cb5aed63 100644 --- a/src/ChangeLog +++ b/src/ChangeLog | |||
| @@ -1,5 +1,15 @@ | |||
| 1 | 2013-02-08 Dmitry Antipov <dmantipov@yandex.ru> | 1 | 2013-02-08 Dmitry Antipov <dmantipov@yandex.ru> |
| 2 | 2 | ||
| 3 | * search.c (scan_buffer): Calculate end byte position just once. | ||
| 4 | (scan_newline): Do not recalculate start_byte. | ||
| 5 | (search_command): Use eassert. | ||
| 6 | * syntax.c (struct lisp_parse_state): New member location_byte. | ||
| 7 | (scan_sexps_forward): Record from_byte and avoid redundant | ||
| 8 | character to byte position calculation ... | ||
| 9 | (Fparse_partial_sexp): ... here. Break too long line. | ||
| 10 | |||
| 11 | 2013-02-08 Dmitry Antipov <dmantipov@yandex.ru> | ||
| 12 | |||
| 3 | * lisp.h (make_uninit_vector): New function. | 13 | * lisp.h (make_uninit_vector): New function. |
| 4 | * alloc.c (Fvector, Fmake_byte_code): | 14 | * alloc.c (Fvector, Fmake_byte_code): |
| 5 | * ccl.c (Fregister_ccl_program): | 15 | * ccl.c (Fregister_ccl_program): |
diff --git a/src/search.c b/src/search.c index 545f614a063..c4ccf6c257b 100644 --- a/src/search.c +++ b/src/search.c | |||
| @@ -644,18 +644,23 @@ scan_buffer (int target, ptrdiff_t start, ptrdiff_t end, | |||
| 644 | ptrdiff_t count, ptrdiff_t *shortage, bool allow_quit) | 644 | ptrdiff_t count, ptrdiff_t *shortage, bool allow_quit) |
| 645 | { | 645 | { |
| 646 | struct region_cache *newline_cache; | 646 | struct region_cache *newline_cache; |
| 647 | ptrdiff_t end_byte = -1; | ||
| 647 | int direction; | 648 | int direction; |
| 648 | 649 | ||
| 649 | if (count > 0) | 650 | if (count > 0) |
| 650 | { | 651 | { |
| 651 | direction = 1; | 652 | direction = 1; |
| 652 | if (! end) end = ZV; | 653 | if (!end) |
| 654 | end = ZV, end_byte = ZV_BYTE; | ||
| 653 | } | 655 | } |
| 654 | else | 656 | else |
| 655 | { | 657 | { |
| 656 | direction = -1; | 658 | direction = -1; |
| 657 | if (! end) end = BEGV; | 659 | if (!end) |
| 660 | end = BEGV, end_byte = BEGV_BYTE; | ||
| 658 | } | 661 | } |
| 662 | if (end_byte == -1) | ||
| 663 | end_byte = CHAR_TO_BYTE (end); | ||
| 659 | 664 | ||
| 660 | newline_cache_on_off (current_buffer); | 665 | newline_cache_on_off (current_buffer); |
| 661 | newline_cache = current_buffer->newline_cache; | 666 | newline_cache = current_buffer->newline_cache; |
| @@ -673,7 +678,7 @@ scan_buffer (int target, ptrdiff_t start, ptrdiff_t end, | |||
| 673 | the position of the last character before the next such | 678 | the position of the last character before the next such |
| 674 | obstacle --- the last character the dumb search loop should | 679 | obstacle --- the last character the dumb search loop should |
| 675 | examine. */ | 680 | examine. */ |
| 676 | ptrdiff_t ceiling_byte = CHAR_TO_BYTE (end) - 1; | 681 | ptrdiff_t ceiling_byte = end_byte - 1; |
| 677 | ptrdiff_t start_byte; | 682 | ptrdiff_t start_byte; |
| 678 | ptrdiff_t tem; | 683 | ptrdiff_t tem; |
| 679 | 684 | ||
| @@ -750,7 +755,7 @@ scan_buffer (int target, ptrdiff_t start, ptrdiff_t end, | |||
| 750 | while (start > end) | 755 | while (start > end) |
| 751 | { | 756 | { |
| 752 | /* The last character to check before the next obstacle. */ | 757 | /* The last character to check before the next obstacle. */ |
| 753 | ptrdiff_t ceiling_byte = CHAR_TO_BYTE (end); | 758 | ptrdiff_t ceiling_byte = end_byte; |
| 754 | ptrdiff_t start_byte; | 759 | ptrdiff_t start_byte; |
| 755 | ptrdiff_t tem; | 760 | ptrdiff_t tem; |
| 756 | 761 | ||
| @@ -861,8 +866,6 @@ scan_newline (ptrdiff_t start, ptrdiff_t start_byte, | |||
| 861 | if (allow_quit) | 866 | if (allow_quit) |
| 862 | immediate_quit++; | 867 | immediate_quit++; |
| 863 | 868 | ||
| 864 | start_byte = CHAR_TO_BYTE (start); | ||
| 865 | |||
| 866 | if (count > 0) | 869 | if (count > 0) |
| 867 | { | 870 | { |
| 868 | while (start_byte < limit_byte) | 871 | while (start_byte < limit_byte) |
| @@ -1016,8 +1019,7 @@ search_command (Lisp_Object string, Lisp_Object bound, Lisp_Object noerror, | |||
| 1016 | 1019 | ||
| 1017 | if (!EQ (noerror, Qt)) | 1020 | if (!EQ (noerror, Qt)) |
| 1018 | { | 1021 | { |
| 1019 | if (lim < BEGV || lim > ZV) | 1022 | eassert (BEGV <= lim && lim <= ZV); |
| 1020 | emacs_abort (); | ||
| 1021 | SET_PT_BOTH (lim, lim_byte); | 1023 | SET_PT_BOTH (lim, lim_byte); |
| 1022 | return Qnil; | 1024 | return Qnil; |
| 1023 | #if 0 /* This would be clean, but maybe programs depend on | 1025 | #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 | return Qnil; | 1031 | return Qnil; |
| 1030 | } | 1032 | } |
| 1031 | 1033 | ||
| 1032 | if (np < BEGV || np > ZV) | 1034 | eassert (BEGV <= np && np <= ZV); |
| 1033 | emacs_abort (); | ||
| 1034 | |||
| 1035 | SET_PT (np); | 1035 | SET_PT (np); |
| 1036 | 1036 | ||
| 1037 | return make_number (np); | 1037 | return make_number (np); |
diff --git a/src/syntax.c b/src/syntax.c index 6febcd266c0..42500b0cb76 100644 --- a/src/syntax.c +++ b/src/syntax.c | |||
| @@ -121,6 +121,7 @@ struct lisp_parse_state | |||
| 121 | /* Char number of start of containing expression */ | 121 | /* Char number of start of containing expression */ |
| 122 | ptrdiff_t prevlevelstart; | 122 | ptrdiff_t prevlevelstart; |
| 123 | ptrdiff_t location; /* Char number at which parsing stopped. */ | 123 | ptrdiff_t location; /* Char number at which parsing stopped. */ |
| 124 | ptrdiff_t location_byte; /* Corresponding byte position. */ | ||
| 124 | ptrdiff_t comstr_start; /* Position of last comment/string starter. */ | 125 | ptrdiff_t comstr_start; /* Position of last comment/string starter. */ |
| 125 | Lisp_Object levelstarts; /* Char numbers of starts-of-expression | 126 | Lisp_Object levelstarts; /* Char numbers of starts-of-expression |
| 126 | of levels (starting from outermost). */ | 127 | of levels (starting from outermost). */ |
| @@ -3288,6 +3289,7 @@ do { prev_from = from; \ | |||
| 3288 | state.prevlevelstart | 3289 | state.prevlevelstart |
| 3289 | = (curlevel == levelstart) ? -1 : (curlevel - 1)->last; | 3290 | = (curlevel == levelstart) ? -1 : (curlevel - 1)->last; |
| 3290 | state.location = from; | 3291 | state.location = from; |
| 3292 | state.location_byte = from_byte; | ||
| 3291 | state.levelstarts = Qnil; | 3293 | state.levelstarts = Qnil; |
| 3292 | while (curlevel > levelstart) | 3294 | while (curlevel > levelstart) |
| 3293 | state.levelstarts = Fcons (make_number ((--curlevel)->last), | 3295 | state.levelstarts = Fcons (make_number ((--curlevel)->last), |
| @@ -3327,7 +3329,8 @@ Fifth arg OLDSTATE is a list like what this function returns. | |||
| 3327 | Sixth arg COMMENTSTOP non-nil means stop at the start of a comment. | 3329 | Sixth arg COMMENTSTOP non-nil means stop at the start of a comment. |
| 3328 | If it is symbol `syntax-table', stop after the start of a comment or a | 3330 | If it is symbol `syntax-table', stop after the start of a comment or a |
| 3329 | string, or after end of a comment or a string. */) | 3331 | string, or after end of a comment or a string. */) |
| 3330 | (Lisp_Object from, Lisp_Object to, Lisp_Object targetdepth, Lisp_Object stopbefore, Lisp_Object oldstate, Lisp_Object commentstop) | 3332 | (Lisp_Object from, Lisp_Object to, Lisp_Object targetdepth, |
| 3333 | Lisp_Object stopbefore, Lisp_Object oldstate, Lisp_Object commentstop) | ||
| 3331 | { | 3334 | { |
| 3332 | struct lisp_parse_state state; | 3335 | struct lisp_parse_state state; |
| 3333 | EMACS_INT target; | 3336 | EMACS_INT target; |
| @@ -3347,7 +3350,7 @@ Sixth arg COMMENTSTOP non-nil means stop at the start of a comment. | |||
| 3347 | (NILP (commentstop) | 3350 | (NILP (commentstop) |
| 3348 | ? 0 : (EQ (commentstop, Qsyntax_table) ? -1 : 1))); | 3351 | ? 0 : (EQ (commentstop, Qsyntax_table) ? -1 : 1))); |
| 3349 | 3352 | ||
| 3350 | SET_PT (state.location); | 3353 | SET_PT_BOTH (state.location, state.location_byte); |
| 3351 | 3354 | ||
| 3352 | return Fcons (make_number (state.depth), | 3355 | return Fcons (make_number (state.depth), |
| 3353 | Fcons (state.prevlevelstart < 0 | 3356 | Fcons (state.prevlevelstart < 0 |