diff options
| author | Yukihiro "Matz" Matsumoto <[email protected]> | 2017-07-27 15:47:03 +0900 |
|---|---|---|
| committer | Yukihiro "Matz" Matsumoto <[email protected]> | 2017-07-27 16:14:03 +0900 |
| commit | 1e41026b28edbb6423b65588d5aeb270df2e0032 (patch) | |
| tree | 3672222c23e7fce5ca6e756258f737f2328ee117 | |
| parent | f26d00d9e81b102fababdd9c0d1b886fab30e35a (diff) | |
| download | mruby-1e41026b28edbb6423b65588d5aeb270df2e0032.tar.gz mruby-1e41026b28edbb6423b65588d5aeb270df2e0032.zip | |
Always use `MRB_USE_IV_SEGLIST`.
| -rw-r--r-- | doc/guides/mrbconf.md | 11 | ||||
| -rw-r--r-- | examples/targets/build_config_ArduinoDue.rb | 1 | ||||
| -rw-r--r-- | examples/targets/build_config_RX630.rb | 1 | ||||
| -rw-r--r-- | examples/targets/build_config_chipKITMax32.rb | 1 | ||||
| -rw-r--r-- | include/mrbconf.h | 6 | ||||
| -rw-r--r-- | src/variable.c | 111 |
6 files changed, 0 insertions, 131 deletions
diff --git a/doc/guides/mrbconf.md b/doc/guides/mrbconf.md index fabd7208b..eb27ad102 100644 --- a/doc/guides/mrbconf.md +++ b/doc/guides/mrbconf.md @@ -122,20 +122,9 @@ largest value of required alignment. * If defined `Float` will be a mruby object with `RBasic`. ## Instance variable configuration. -`MRB_USE_IV_SEGLIST` -* If defined enable segmented list in instance variable table instead of khash. -* Segmented list is a linked list of key and value segments. -* It will linear search instead of hash search. - `MRB_SEGMENT_SIZE` * Default value is `4`. * Specifies size of each segment in segment list. -* Ignored when `MRB_USE_IV_SEGLIST` isn't defined. - -`MRB_IVHASH_INIT_SIZE` -* Default value is `8`. -* Specifies initial size for instance variable table. -* Ignored when `MRB_USE_IV_SEGLIST` is defined. ## Other configuration. `MRB_UTF8_STRING` diff --git a/examples/targets/build_config_ArduinoDue.rb b/examples/targets/build_config_ArduinoDue.rb index 740dcfa02..527aaa4f6 100644 --- a/examples/targets/build_config_ArduinoDue.rb +++ b/examples/targets/build_config_ArduinoDue.rb @@ -46,7 +46,6 @@ MRuby::CrossBuild.new("ArduinoDue") do |conf| #configuration for low memory environment cc.defines << %w(MRB_HEAP_PAGE_SIZE=64) - cc.defines << %w(MRB_USE_IV_SEGLIST) cc.defines << %w(KHASH_DEFAULT_SIZE=8) cc.defines << %w(MRB_STR_BUF_MIN_SIZE=20) cc.defines << %w(MRB_GC_STRESS) diff --git a/examples/targets/build_config_RX630.rb b/examples/targets/build_config_RX630.rb index 8e387c29d..fd17eae99 100644 --- a/examples/targets/build_config_RX630.rb +++ b/examples/targets/build_config_RX630.rb @@ -32,7 +32,6 @@ MRuby::CrossBuild.new("RX630") do |conf| #configuration for low memory environment cc.defines << %w(MRB_USE_FLOAT) cc.defines << %w(MRB_HEAP_PAGE_SIZE=64) - cc.defines << %w(MRB_USE_IV_SEGLIST) cc.defines << %w(KHASH_DEFAULT_SIZE=8) cc.defines << %w(MRB_STR_BUF_MIN_SIZE=20) cc.defines << %w(MRB_GC_STRESS) diff --git a/examples/targets/build_config_chipKITMax32.rb b/examples/targets/build_config_chipKITMax32.rb index c3a146e4e..951f71483 100644 --- a/examples/targets/build_config_chipKITMax32.rb +++ b/examples/targets/build_config_chipKITMax32.rb @@ -43,7 +43,6 @@ MRuby::CrossBuild.new("chipKITMax32") do |conf| #configuration for low memory environment cc.defines << %w(MRB_HEAP_PAGE_SIZE=64) - cc.defines << %w(MRB_USE_IV_SEGLIST) cc.defines << %w(KHASH_DEFAULT_SIZE=8) cc.defines << %w(MRB_STR_BUF_MIN_SIZE=20) cc.defines << %w(MRB_GC_STRESS) diff --git a/include/mrbconf.h b/include/mrbconf.h index 4796919c2..b246b970c 100644 --- a/include/mrbconf.h +++ b/include/mrbconf.h @@ -52,12 +52,6 @@ /* number of object per heap page */ //#define MRB_HEAP_PAGE_SIZE 1024 -/* use segmented list for IV table */ -//#define MRB_USE_IV_SEGLIST - -/* initial size for IV khash; ignored when MRB_USE_IV_SEGLIST is set */ -//#define MRB_IVHASH_INIT_SIZE 8 - /* if _etext and _edata available, mruby can reduce memory used by symbols */ //#define MRB_USE_ETEXT_EDATA diff --git a/src/variable.c b/src/variable.c index ffe8b954b..481361928 100644 --- a/src/variable.c +++ b/src/variable.c @@ -12,8 +12,6 @@ typedef int (iv_foreach_func)(mrb_state*,mrb_sym,mrb_value,void*); -#ifdef MRB_USE_IV_SEGLIST - #ifndef MRB_SEGMENT_SIZE #define MRB_SEGMENT_SIZE 4 #endif @@ -280,115 +278,6 @@ iv_free(mrb_state *mrb, iv_tbl *t) mrb_free(mrb, t); } -#else - -#include <mruby/khash.h> - -#ifndef MRB_IVHASH_INIT_SIZE -#define MRB_IVHASH_INIT_SIZE 8 -#endif - -KHASH_DECLARE(iv, mrb_sym, mrb_value, TRUE) -KHASH_DEFINE(iv, mrb_sym, mrb_value, TRUE, kh_int_hash_func, kh_int_hash_equal) - -typedef struct iv_tbl { - khash_t(iv) h; -} iv_tbl; - -static iv_tbl* -iv_new(mrb_state *mrb) -{ - return (iv_tbl*)kh_init_size(iv, mrb, MRB_IVHASH_INIT_SIZE); -} - -static void -iv_put(mrb_state *mrb, iv_tbl *t, mrb_sym sym, mrb_value val) -{ - khash_t(iv) *h = &t->h; - khiter_t k; - - k = kh_put(iv, mrb, h, sym); - kh_value(h, k) = val; -} - -static mrb_bool -iv_get(mrb_state *mrb, iv_tbl *t, mrb_sym sym, mrb_value *vp) -{ - khash_t(iv) *h = &t->h; - khiter_t k; - - k = kh_get(iv, mrb, h, sym); - if (k != kh_end(h)) { - if (vp) *vp = kh_value(h, k); - return TRUE; - } - return FALSE; -} - -static mrb_bool -iv_del(mrb_state *mrb, iv_tbl *t, mrb_sym sym, mrb_value *vp) -{ - khash_t(iv) *h = &t->h; - khiter_t k; - - if (h) { - k = kh_get(iv, mrb, h, sym); - if (k != kh_end(h)) { - mrb_value val = kh_value(h, k); - kh_del(iv, mrb, h, k); - if (vp) *vp = val; - return TRUE; - } - } - return FALSE; -} - -static mrb_bool -iv_foreach(mrb_state *mrb, iv_tbl *t, iv_foreach_func *func, void *p) -{ - khash_t(iv) *h = &t->h; - khiter_t k; - int n; - - if (h) { - for (k = kh_begin(h); k != kh_end(h); k++) { - if (kh_exist(h, k)) { - n = (*func)(mrb, kh_key(h, k), kh_value(h, k), p); - if (n > 0) return FALSE; - if (n < 0) { - kh_del(iv, mrb, h, k); - } - } - } - } - return TRUE; -} - -static size_t -iv_size(mrb_state *mrb, iv_tbl *t) -{ - khash_t(iv) *h; - - if (t && (h = &t->h)) { - return kh_size(h); - } - return 0; -} - -static iv_tbl* -iv_copy(mrb_state *mrb, iv_tbl *t) -{ - return (iv_tbl*)kh_copy(iv, mrb, &t->h); -} - -static void -iv_free(mrb_state *mrb, iv_tbl *t) -{ - kh_destroy(iv, mrb, &t->h); -} - -#endif - static int iv_mark_i(mrb_state *mrb, mrb_sym sym, mrb_value v, void *p) { |
