mirror of
https://github.com/mruby/mruby
synced 2026-06-08 16:11:16 +00:00
95656c40ff
During mrb_state initialization, especially when defining core classes and methods, the method cache is repeatedly cleared. This causes significant overhead in scenarios like mrbtest where mrb_state is initialized multiple times. This commit introduces a `bootstrapping` flag in `struct mrb_state`. When this flag is TRUE (during mrb_open_core), method cache clears triggered by `mrb_define_method_raw` and `include_module_at` are suppressed. The cache is cleared only once at the very end of `mrb_open_core` after all core methods are defined, and the flag is then set to FALSE. This optimization significantly reduces the number of method cache clears during initialization, improving performance for repeated mrb_state creations. Co-authored-by: Gemini <gemini@google.com>