diff options
author | Thiago de Arruda <tpadilha84@gmail.com> | 2014-09-12 14:01:35 -0300 |
---|---|---|
committer | Thiago de Arruda <tpadilha84@gmail.com> | 2014-09-12 14:01:35 -0300 |
commit | 6a8932aa588b8631e66255fb24e2776acdd46c8e (patch) | |
tree | 2f8b63891e478fdc40fc37cf03b029ebbb7f51a5 /src/nvim/map.c | |
parent | 042aca6eb4d0fe9e6ddf3bcfb96a39838b2633d1 (diff) | |
parent | 2a67b847aa2074f688fce9f96e060eeb5ba29435 (diff) | |
download | rneovim-6a8932aa588b8631e66255fb24e2776acdd46c8e.tar.gz rneovim-6a8932aa588b8631e66255fb24e2776acdd46c8e.tar.bz2 rneovim-6a8932aa588b8631e66255fb24e2776acdd46c8e.zip |
Merge PR #1130 'Update to the experimental msgpack v5 branch'
Diffstat (limited to 'src/nvim/map.c')
-rw-r--r-- | src/nvim/map.c | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/src/nvim/map.c b/src/nvim/map.c index 2e47e8b249..24aa38d67d 100644 --- a/src/nvim/map.c +++ b/src/nvim/map.c @@ -1,10 +1,12 @@ #include <stdlib.h> #include <stdbool.h> +#include <string.h> #include "nvim/map.h" #include "nvim/map_defs.h" #include "nvim/vim.h" #include "nvim/memory.h" +#include "nvim/os/msgpack_rpc.h" #include "nvim/lib/khash.h" @@ -87,7 +89,23 @@ return rv; \ } +static inline khint_t String_hash(String s) +{ + khint_t h = 0; + for (size_t i = 0; i < s.size && s.data[i]; i++) { + h = (h << 5) - h + (uint8_t)s.data[i]; + } + return h; +} + +static inline bool String_eq(String a, String b) +{ + return strncmp(a.data, b.data, min(a.size, b.size)) == 0; +} + + MAP_IMPL(cstr_t, uint64_t, DEFAULT_INITIALIZER) MAP_IMPL(cstr_t, ptr_t, DEFAULT_INITIALIZER) MAP_IMPL(ptr_t, ptr_t, DEFAULT_INITIALIZER) MAP_IMPL(uint64_t, ptr_t, DEFAULT_INITIALIZER) +MAP_IMPL(String, rpc_method_handler_fn, DEFAULT_INITIALIZER) |