2017-03-23 11:34 GMT+03:00 Dominique Pellé <vim-dev-git...@256bit.org>:
> @jamessan wrote:
>
> You could use something like gperf or triehash to generate the hash table at
> build time.
> gperf is widely available, but triehash is a simple Perl script with a
> permissive license,
> so it could probably just be included.
>
> I like it. If gperf is used, we can consider checking-in the generated C
> code,
> so regular users who compile Vim don't have to install gperf.
> Only developers who add new Ex commands (that's rare) would have to
> install gperf. I don't have experience with gperf but at first sight it
> looks simple to use and produce well optimized code.

Neovim has it as a build-time dependency, you may search for GPERF_CMD
in src/nvim/CMakeLists.txt, generated file (funcs.generated.h) is then
included in eval.c.

But I do not like the solution much:

1. What are keys? Do not forget that commands may be abbreviated.
2. You can’t use gperf for user commands. I think that ideally user
commands should use the same solution: currently it is O(N) linear
search, without even any optimizations built-in commands have!

Aren’t there some structures designed specifically for this (finding
word by its first N characters) task? E.g. trie/prefix tree. For
built-in commands that could be built at build time, for user commands
it should be built at runtime, finding actual command inside should
share code for both built-in and user commands.

>
> —
> You are receiving this because you are subscribed to this thread.
> Reply to this email directly, view it on GitHub
>
> --
> --
> You received this message from the "vim_dev" 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_dev" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to vim_dev+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

-- 
-- 
You received this message from the "vim_dev" 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_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to vim_dev+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Raspunde prin e-mail lui