Branch: Tag:

2016-10-21

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

Mapping: Added flag MAPPING_FLAG_NO_SHRINK.

This is a flag that disables shrinking of the mapping_data hashtable
when the number of elements goes below the MIN_LINK_LENGTH threshold.
It is intended to be used by code that has mappings with a high
rotation of content (ie lots of mixed insertions and deletions).

1182:    m->debug_size--;   #endif    +  if (!(md->flags & MAPPING_FLAG_NO_SHRINK)) {    if((md->size < md->hashsize * MIN_LINK_LENGTH) &&    (md->hashsize > AVG_LINK_LENGTH)) {    debug_malloc_touch(m);    rehash(m, MAP_SLOTS(m->data->size));    } -  +  }      #ifdef PIKE_DEBUG    if(d_flag>1) check_mapping(m);
1257:    md->val_types = val_types;    md->ind_types = ind_types;    +  if (!(md->flags & MAPPING_FLAG_NO_SHRINK)) {    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));    } -  +  }      #ifdef PIKE_DEBUG    if(d_flag>1) check_mapping(m);