Starting to look for a multibyte character not at the start of the string,
but only as far back as such a character can possibly be. Speedup suggested by Mark Majeres. git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5147 35c25a1d-7b9e-4130-9fde-d3aeb78583b8master
parent
cb776fad88
commit
76e7aaf514
|
@ -1,3 +1,8 @@
|
||||||
|
2015-03-22 Benno Schulenberg <bensberg@justemail.net>
|
||||||
|
* src/chars.c (move_mbleft): Start looking for a multibyte char
|
||||||
|
not at the start of the string, but only as far back as such a
|
||||||
|
char can possibly be. Change suggested by Mark Majeres.
|
||||||
|
|
||||||
2015-03-21 Benno Schulenberg <bensberg@justemail.net>
|
2015-03-21 Benno Schulenberg <bensberg@justemail.net>
|
||||||
* src/text.c (do_alt_speller): Remove some leftovers.
|
* src/text.c (do_alt_speller): Remove some leftovers.
|
||||||
* src/search.c: Place some comments better and unwrap some lines.
|
* src/search.c: Place some comments better and unwrap some lines.
|
||||||
|
|
10
src/chars.c
10
src/chars.c
|
@ -484,12 +484,18 @@ int parse_mbchar(const char *buf, char *chr, size_t *col)
|
||||||
* before the one at pos. */
|
* before the one at pos. */
|
||||||
size_t move_mbleft(const char *buf, size_t pos)
|
size_t move_mbleft(const char *buf, size_t pos)
|
||||||
{
|
{
|
||||||
size_t before = 0, char_len = 0;
|
size_t before, char_len = 0;
|
||||||
|
|
||||||
assert(buf != NULL && pos <= strlen(buf));
|
assert(buf != NULL && pos <= strlen(buf));
|
||||||
|
|
||||||
/* There is no library function to move backward one multibyte
|
/* There is no library function to move backward one multibyte
|
||||||
* character. Here is the naive, O(pos) way to do it. */
|
* character. So we just start groping for one at the farthest
|
||||||
|
* possible point. */
|
||||||
|
if (mb_cur_max() > pos)
|
||||||
|
before = 0;
|
||||||
|
else
|
||||||
|
before = pos - mb_cur_max();
|
||||||
|
|
||||||
while (before < pos) {
|
while (before < pos) {
|
||||||
char_len = parse_mbchar(buf + before, NULL, NULL);
|
char_len = parse_mbchar(buf + before, NULL, NULL);
|
||||||
before += char_len;
|
before += char_len;
|
||||||
|
|
Loading…
Reference in New Issue