From 8619ba6a3850145981c0ee6e86e12a7e25946705 Mon Sep 17 00:00:00 2001 From: "Yukihiro \"Matz\" Matsumoto" Date: Wed, 15 Sep 2021 12:44:31 +0900 Subject: Use `struct` initializer instead of `memset`. --- src/class.c | 4 +++- src/vm.c | 4 ---- 2 files changed, 3 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/class.c b/src/class.c index b683deda0..402a70f6a 100644 --- a/src/class.c +++ b/src/class.c @@ -1698,7 +1698,9 @@ mrb_define_module_function(mrb_state *mrb, struct RClass *c, const char *name, m static void mc_clear(mrb_state *mrb) { - memset(mrb->cache, 0, MRB_METHOD_CACHE_SIZE*sizeof(mrb->cache[0])); + for (int i=0; icache[i] = (struct mrb_cache_entry){0}; + } } void diff --git a/src/vm.c b/src/vm.c index 13b466aec..95458774b 100644 --- a/src/vm.c +++ b/src/vm.c @@ -86,14 +86,10 @@ void mrb_method_missing(mrb_state *mrb, mrb_sym name, mrb_value self, mrb_value static inline void stack_clear(mrb_value *from, size_t count) { -#ifdef MRB_NAN_BOXING while (count-- > 0) { SET_NIL_VALUE(*from); from++; } -#else - memset(from, 0, sizeof(mrb_value)*count); -#endif } static inline void -- cgit v1.2.3