Handle race condition on get->set new cached string

overwrite add if it somehow was added from another thread in between lock checks
This commit is contained in:
Kurt 2020-05-19 20:40:51 -07:00
parent 232a9de32e
commit cce3d5d9f5

View file

@ -51,7 +51,7 @@ namespace PKHeX.Core
// match found, cache result
regMatch = pattern;
lock (dictLock)
Lookup.Add(msg, regMatch);
Lookup[msg] = regMatch;
return true;
}
@ -60,7 +60,7 @@ namespace PKHeX.Core
{
if ((Lookup.Count & ~MAX_COUNT) != 0)
Lookup.Clear(); // reset
Lookup.Add(msg, regMatch = NoMatch);
Lookup[msg] = regMatch = NoMatch;
}
return false;
}