Faster method of moving objects from a temporary cache list to indexed cache lists
This commit is contained in:
@@ -48,18 +48,17 @@ namespace VEPROMS.CSLA.Library
|
||||
private static Dictionary<string, List<PartInfo>> _CacheByPrimaryKey = new Dictionary<string, List<PartInfo>>();
|
||||
private static void ConvertListToDictionary()
|
||||
{
|
||||
List<PartInfo> remove = new List<PartInfo>();
|
||||
foreach (PartInfo tmp in _CacheList)
|
||||
while (_CacheList.Count > 0) // Move PartInfo(s) from temporary _CacheList to _CacheByPrimaryKey
|
||||
{
|
||||
if (!_CacheByPrimaryKey.ContainsKey(tmp.ContentID.ToString() + "_" + tmp.FromType.ToString()))
|
||||
PartInfo tmp = _CacheList[0]; // Get the first PartInfo
|
||||
string pKey = tmp.ContentID.ToString() + "_" + tmp.FromType.ToString();
|
||||
if (!_CacheByPrimaryKey.ContainsKey(pKey))
|
||||
{
|
||||
_CacheByPrimaryKey[tmp.ContentID.ToString() + "_" + tmp.FromType.ToString()] = new List<PartInfo>(); // Add new list for PrimaryKey
|
||||
_CacheByPrimaryKey[pKey] = new List<PartInfo>(); // Add new list for PrimaryKey
|
||||
}
|
||||
_CacheByPrimaryKey[tmp.ContentID.ToString() + "_" + tmp.FromType.ToString()].Add(tmp); // Add to Primary Key list
|
||||
remove.Add(tmp);
|
||||
_CacheByPrimaryKey[pKey].Add(tmp); // Add to Primary Key list
|
||||
_CacheList.RemoveAt(0); // Remove the first PartInfo
|
||||
}
|
||||
foreach (PartInfo tmp in remove)
|
||||
RemoveFromCache(tmp);
|
||||
}
|
||||
internal static void AddList(PartInfoList lst)
|
||||
{
|
||||
|
Reference in New Issue
Block a user