protected void checkMapSize ( ) { if ( ( map instanceof EmbeddedSlotMap ) && map . size ( ) >= LARGE_HASH_SIZE ) { SlotMap newMap = new HashSlotMap ( ) ; for ( Slot s : map ) { newMap . addSlot ( s ) ; } map = newMap ; } }
Before inserting a new item in the map check and see if we need to expand from the embedded map to a HashMap that is more robust against large numbers of hash collisions .