[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Nano-devel] adding a word-completion feature to nano

From: Benno Schulenberg
Subject: Re: [Nano-devel] adding a word-completion feature to nano
Date: Sun, 11 Dec 2016 18:02:08 +0100

Hello Sumedh,

On Sun, Dec 11, 2016, at 14:01, Sumedh Pendurkar wrote:
> I think after first character matches; we should check if the previous
> character is not a word forming character and then start comparing
> next characters. This would avoid redundant checking.

But... checking for the word-formingness of the preceding character
is a *costly* operation: it involves three library calls: mbtowc(),
iswalnum(), mblen() -- the latter probably two or three times, not
to speak of the several intermediate calls and calculations.  That
is a lot of cycles.  In that time we can probably compare something
like ten pairs of bytes, and will find most of the time a mismatch
within the first three or four pairs or so, meaning we don't have
to waste time on the costly preceding-character check.  Meaning
that on average the 'for (i = pletion_x...)' loop will run faster.

In commit 88fb50e0 in the word-completion branch (if you still have
it in your repo) I specifically applied the opposite of your patch.


-- - The professional email service

reply via email to

[Prev in Thread] Current Thread [Next in Thread]