Always use `MRB_USE_IV_SEGLIST`.

parent f26d00d9
......@@ -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`
......
......@@ -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)
......
......@@ -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)
......
......@@ -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)
......
......@@ -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
......
......@@ -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)
{
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment