mirror of
https://github.com/mruby/mruby
synced 2026-06-08 16:11:16 +00:00
mruby-set: replace khash dependency with embedded kset implementation
Replace the external khash dependency with a custom, memory-optimized kset implementation that embeds directly into struct RSet. This change significantly reduces memory consumption and eliminates the need for khash.h inclusion. Implemented by: Rovo Dev Key improvements: - Embedded kset_t directly in struct RSet (exactly 3 pointers in size) - Combined memory layout: [keys...][flags...] in single allocation - Eliminated pointer indirection for better cache performance - Removed dependency on khash.h and related types (khint_t, khiter_t) - Maintained full API compatibility with existing mruby-set interface - Optimized for mrb_value keys with custom hash and equality functions Technical details: - kset_t structure: void *data, uint32_t n_buckets, uint32_t size - Open addressing with linear probing for collision resolution - 2-bit flags per bucket (empty/deleted) packed efficiently - Power-of-2 bucket sizing with 75% load factor upper bound - Integrated GC marking and memory management Memory savings: - Eliminates separate khash_t allocation and pointer storage - Reduces struct RSet from 4 pointers to 3 pointers + embedded data - More efficient memory layout with better locality of reference All existing functionality preserved including set operations, iteration, comparison methods, and Ruby-level API compatibility.
This commit is contained in:
+576
-277
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user