mirror of
https://github.com/mruby/mruby
synced 2026-06-08 16:11:16 +00:00
symbol.c: implement adaptive symbol table for memory efficiency
Replace fixed 256-element hash array in mrb_state with adaptive approach: - Linear search for <=255 symbols (typical embedded use case) - Hash table allocated on-demand when symbols exceed threshold - Reduces mrb_state size by 1KB per instance (1068->36 bytes in symbol fields) - Configurable threshold via MRB_SYMBOL_LINEAR_THRESHOLD in mrbconf.h Co-authored-by: Claude <noreply@anthropic.com>
This commit is contained in:
+2
-3
@@ -155,6 +155,7 @@ typedef uint8_t mrb_code;
|
||||
typedef uint32_t mrb_aspec;
|
||||
|
||||
typedef struct mrb_irep mrb_irep;
|
||||
|
||||
struct mrb_state;
|
||||
|
||||
#ifndef MRB_FIXED_STATE_ATEXIT_STACK_SIZE
|
||||
@@ -281,10 +282,8 @@ typedef struct mrb_state {
|
||||
|
||||
mrb_sym symidx;
|
||||
const char **symtbl;
|
||||
uint8_t *symlink;
|
||||
uint8_t *symflags;
|
||||
mrb_sym symhash[256];
|
||||
size_t symcapa;
|
||||
struct mrb_sym_hash_table *symhash;
|
||||
#ifndef MRB_USE_ALL_SYMBOLS
|
||||
char symbuf[8]; /* buffer for small symbol names */
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user