public override string Add( char[] key, int start, int len ) {
if ( len == 0 ) {
return string.Empty;
}
int hashCode = len + hashCodeRandomizer;
hashCode += ( hashCode << 7 ) ^ key[start]; // this will throw IndexOutOfRangeException in case the start index is invalid
int end = start+len;
for ( int i = start + 1; i < end; i++) {
hashCode += ( hashCode << 7 ) ^ key[i];
}
// mix it a bit more
hashCode -= hashCode >> 17;
hashCode -= hashCode >> 11;
hashCode -= hashCode >> 5;
for ( Entry e = entries[hashCode & mask]; e != null; e = e.next ) {
if ( e.hashCode == hashCode && TextEquals( e.str, key, start ) ) {
return e.str;
}
}
return AddEntry( new string( key, start, len ), hashCode );
}