badvpn/ncd/NCDMethodIndex_hash.h
ambrop7 0ef729228f ncd: speed up module lookup when initializing statements. For non-method statements, cache the module pointer in NCDInterpBlock. For
method statements, keep a global structure of methods grouped by method name, and store indices into this structure into 
NCDInterpBlock. This way, when a method statement is initialized, we only need to traverse a list of all methods with the right name 
and find the one with the right object type. This is very fast because there are few collisions (different object types with the same 
method names).
2012-08-06 13:40:58 +00:00

13 lines
761 B
C

#define CHASH_PARAM_NAME NCDMethodIndex__Hash
#define CHASH_PARAM_ENTRY NCDMethodIndex__hashentry
#define CHASH_PARAM_LINK int
#define CHASH_PARAM_KEY NCDMethodIndex__hashkey
#define CHASH_PARAM_ARG NCDMethodIndex__hasharg
#define CHASH_PARAM_NULL ((int)-1)
#define CHASH_PARAM_DEREF(arg, link) (&(arg)[(link)])
#define CHASH_PARAM_ENTRYHASH(arg, entry) (badvpn_djb2_hash((const uint8_t *)(entry).ptr->method_name))
#define CHASH_PARAM_KEYHASH(arg, key) (badvpn_djb2_hash((const uint8_t *)(key)))
#define CHASH_PARAM_COMPARE_ENTRIES(arg, entry1, entry2) (!strcmp((entry1).ptr->method_name, (entry2).ptr->method_name))
#define CHASH_PARAM_COMPARE_KEY_ENTRY(arg, key1, entry2) (!strcmp((key1), (entry2).ptr->method_name))
#define CHASH_PARAM_ENTRY_NEXT hash_next