Friday, November 21, 2014

Re: :%s//\=@o/gce ignores c flag in key mapping

On 20.11.14 11:54, porphyry5 wrote:
> Annoyingly, I cannot see any clear way to use an associative array in
> this case, because of that pesky word suffix list. I believe 'if
> (word in wd-list)' must either return "no match" or "exact match". In
> the binary search I check for exact matches, on failure immediately
> followed by a partial match test, 'if (word ~ wd-list[index])' to
> indicate the need to append suffixes to the partial matching wd-list
> entry.

Ah ... perhaps the easiest way is to detect recognisable suffixes on
input words, and strip them for the initial match attempt, i.e. only the
part of the word you want is hashed. A flag, or non-null
"found_this_suffix" string variable, retained from the partial-match
generating pre-stripping, then guides any additional actions, if
required.

To cover the case where a word with a recognisable suffix is in the list
with suffix, rather than without, a check-on-match-failure for the
unstripped word could be performed. It would only occur when a suffix is
detected, and would in also be faster than a search.

That essentially reverses the order of match vs suffix handling.
Speed-wise, I'd expect the pre-strip to be quite a bit faster than the
partial match, since the suffix list is unlikely to number 200,000
entries.

Erik

--
Britain had first obtained a commercial Enigma machine back in 1927, by simply
purchasing one in the open in Germany. The machine was analysed and a diagnostic
report written on how it worked. - http://www.bbc.co.uk/news/magazine-17486464

--
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment