Prevent rehash when value is replaced in table.

This commit is contained in:
James Roseborough
2010-04-19 21:39:17 +00:00
parent 797c79fd6d
commit 8bd255a356

View File

@@ -437,14 +437,17 @@ public class LuaTable extends LuaValue {
if ( value.isnil() ) if ( value.isnil() )
hashRemove(key); hashRemove(key);
else { else {
if ( checkLoadFactor() ) if ( hashKeys.length == 0 ) {
rehash(); hashKeys = new LuaValue[ MIN_HASH_CAPACITY ];
hashValues = new LuaValue[ MIN_HASH_CAPACITY ];
}
int slot = hashFindSlot( key ); int slot = hashFindSlot( key );
if ( hashFillSlot( slot, value ) ) if ( hashFillSlot( slot, value ) )
return; return;
hashKeys[slot] = key; hashKeys[slot] = key;
hashValues[slot] = value; hashValues[slot] = value;
if ( checkLoadFactor() )
rehash();
} }
} }