adding MOO_STORE_OOP and MOO_STORE_OOP_TO_ARRAY

This commit is contained in:
hyunghwan.chung 2018-12-04 15:06:56 +00:00
parent 9b48cff37d
commit a7fc55efac
3 changed files with 15 additions and 6 deletions

View File

@ -78,7 +78,8 @@ static moo_oop_oop_t expand_bucket (moo_t* moo, moo_oop_oop_t oldbuc)
index = moo_hashoochars(key->slot, MOO_OBJ_GET_SIZE(key)) % newsz; index = moo_hashoochars(key->slot, MOO_OBJ_GET_SIZE(key)) % newsz;
while (newbuc->slot[index] != moo->_nil) index = (index + 1) % newsz; while (newbuc->slot[index] != moo->_nil) index = (index + 1) % newsz;
newbuc->slot[index] = (moo_oop_t)ass;
MOO_STORE_OOP_TO_ARRAY (moo, newbuc, index, (moo_oop_t)ass); /* newbuc->slot[index] = (moo_oop_t)ass; */
} }
} }
@ -186,7 +187,7 @@ static moo_oop_association_t find_or_upsert (moo_t* moo, moo_oop_dic_t dic, moo_
* it overflows after increment below */ * it overflows after increment below */
MOO_ASSERT (moo, tally < MOO_SMOOI_MAX); MOO_ASSERT (moo, tally < MOO_SMOOI_MAX);
dic->tally = MOO_SMOOI_TO_OOP(tally + 1); dic->tally = MOO_SMOOI_TO_OOP(tally + 1);
dic->bucket->slot[index] = (moo_oop_t)ass; MOO_STORE_OOP_TO_ARRAY (moo, dic->bucket, index, (moo_oop_t)ass); /*dic->bucket->slot[index] = (moo_oop_t)ass;*/
moo_poptmps (moo, tmp_count); moo_poptmps (moo, tmp_count);
return ass; return ass;
@ -321,12 +322,12 @@ found:
if ((y > x && (z <= x || z > y)) || if ((y > x && (z <= x || z > y)) ||
(y < x && (z <= x && z > y))) (y < x && (z <= x && z > y)))
{ {
dic->bucket->slot[x] = dic->bucket->slot[y]; MOO_STORE_OOP_TO_ARRAY (moo, dic->bucket, x, dic->bucket->slot[y]); /*dic->bucket->slot[x] = dic->bucket->slot[y];*/
x = y; x = y;
} }
} }
dic->bucket->slot[x] = moo->_nil; MOO_STORE_OOP_TO_ARRAY (moo, dic->bucket, x, moo->_nil); /*dic->bucket->slot[x] = moo->_nil;*/
tally--; tally--;
dic->tally = MOO_SMOOI_TO_OOP(tally); dic->tally = MOO_SMOOI_TO_OOP(tally);

View File

@ -1838,6 +1838,14 @@ typedef struct moo_synerr_t moo_synerr_t;
extern "C" { extern "C" {
#endif #endif
#if defined(MOO_HAVE_INLINE)
static MOO_INLINE void MOO_STORE_OOP (moo_t* moo, moo_oop_t* rcvaddr, moo_oop_t val) { *rcvaddr = val; }
static MOO_INLINE void MOO_STORE_OOP_TO_ARRAY (moo_t* moo, moo_oop_oop_t rcv, moo_oow_t idx, moo_oop_t val) { MOO_STORE_OOP (moo, &rcv->slot[idx], val); }
#else
# define MOO_STORE_OOP(moo,rcvaddr,val) (*(rcvaddr) = val)
# define MOO_STORE_OOP_TO_ARRAY(moo,rcv,idx,val) MOO_STORE_OOP(moo, &((moo_oop_oop_t)rcv)->slot[idx], val)
#endif
MOO_EXPORT moo_t* moo_open ( MOO_EXPORT moo_t* moo_open (
moo_mmgr_t* mmgr, moo_mmgr_t* mmgr,
moo_oow_t xtnsize, moo_oow_t xtnsize,

View File

@ -441,7 +441,7 @@ moo_pfrc_t moo_pf_basic_at_put (moo_t* moo, moo_mod_t* mod, moo_ooi_t nargs)
} }
case MOO_OBJ_TYPE_OOP: case MOO_OBJ_TYPE_OOP:
((moo_oop_oop_t)rcv)->slot[idx] = val; MOO_STORE_OOP_TO_ARRAY (moo, (moo_oop_oop_t)rcv, idx, val); /*((moo_oop_oop_t)rcv)->slot[idx] = val;*/
break; break;
default: default: