reorder operations and better docs for use case simplification

This commit is contained in:
Richard Thier 2024-10-10 17:16:19 +02:00
parent 047babeb1b
commit c1f0e5f1a9

17
simap.h
View File

@ -7,13 +7,6 @@
#include "amap.h"
#include "arena.h/arena.h"
/** This is to ensure 8byte storage of pointers (with possible padding) */
union simap_ptr64 {
void *ptr;
uint64_t u64;
};
typedef union simap_ptr64 simap_ptr64;
/**
* A "peasantly" map data structure backed by arena.h - basically a toy data structure...
*
@ -64,12 +57,22 @@ static inline simap_instance simap_create() {
return ret;
}
static inline void* simap(void *amap_instance, AMAP_OP op, const char *key, void *ptr);
/** The first 8 characters are stored as uint64_t for fast checks */
union simap_c64 {
char str8[8];
uint64_t u64;
};
typedef union simap_char64 simap_char64;
/** This is to ensure 8byte storage of pointers (with possible padding) */
union simap_ptr64 {
void *ptr;
uint64_t u64;
};
typedef union simap_ptr64 simap_ptr64;
static inline simap_ptr64 *simap_search_internal(simap_instance *map, const char *key) {
/* Construct prefix (fast-key) */
size_t keylen = strlen(key);