Branch: Tag:

2016-10-21

2016-10-21 13:51:46 by Henrik Grubbström (Grubba) <grubba@grubba.org>

Mapping: Don't rehash in vain.

The non-empty mapping hashsize never shrinks below AVG_LINK_LENGTH,
so save some cpu cycles by not attempting to shrink it further.

Attempts to improve performance of encode_value() for objects,
programs and functions.

1185:    m->debug_size--;   #endif    -  if(md->size < (md->hashsize + 1) * MIN_LINK_LENGTH) -  { +  if((md->size < md->hashsize * MIN_LINK_LENGTH) && +  (md->hashsize > AVG_LINK_LENGTH)) {    debug_malloc_touch(m);    rehash(m, MAP_SLOTS(m->data->size));    }
1260:    md->val_types = val_types;    md->ind_types = ind_types;    -  if(MAP_SLOTS(md->size) < md->hashsize * MIN_LINK_LENGTH) -  { +  if((MAP_SLOTS(md->size) < md->hashsize * MIN_LINK_LENGTH) && +  (md->hashsize > AVG_LINK_LENGTH)) {    debug_malloc_touch(m);    rehash(m, MAP_SLOTS(md->size));    }