nostrdb

an unfairly fast embedded nostr database backed by lmdb
git clone git://jb55.com/nostrdb
Log | Files | Refs | Submodules | README | LICENSE

symbol_table.c (553B)


      1  /* Note: only one hash table can be implemented a single file. */
      2 #include "../symbols.h"
      3 #include "hash/hash_table_def.h"
      4 DEFINE_HASH_TABLE(fb_symbol_table)
      5 #include "hash/hash_table_impl.h"
      6 
      7 static inline int ht_match(const void *key, size_t len, fb_symbol_t *sym)
      8 {
      9     return len == ht_key_len(sym) && memcmp(key, ht_key(sym), len) == 0;
     10 }
     11 
     12 static inline const void *ht_key(fb_symbol_t *sym)
     13 {
     14     return sym->ident->text;
     15 }
     16 
     17 static inline size_t ht_key_len(fb_symbol_t *sym)
     18 {
     19     fb_token_t *ident = sym->ident;
     20 
     21     return (size_t)ident->len;
     22 }