Faster method of moving objects from a temporary cache list to indexed cache lists

This commit is contained in:
Rich
2010-09-29 17:21:30 +00:00
parent f3782ea2a2
commit 9f869343cd
55 changed files with 385 additions and 440 deletions

View File

@@ -65,18 +65,17 @@ namespace VEPROMS.CSLA.Library
private static Dictionary<string, List<Part>> _CacheByPrimaryKey = new Dictionary<string, List<Part>>();
private static void ConvertListToDictionary()
{
List<Part> remove = new List<Part>();
foreach (Part tmp in _CacheList)
while (_CacheList.Count > 0) // Move Part(s) from temporary _CacheList to _CacheByPrimaryKey
{
if (!_CacheByPrimaryKey.ContainsKey(tmp.ContentID.ToString() + "_" + tmp.FromType.ToString()))
Part tmp = _CacheList[0]; // Get the first Part
string pKey = tmp.ContentID.ToString() + "_" + tmp.FromType.ToString();
if (!_CacheByPrimaryKey.ContainsKey(pKey))
{
_CacheByPrimaryKey[tmp.ContentID.ToString() + "_" + tmp.FromType.ToString()] = new List<Part>(); // Add new list for PrimaryKey
_CacheByPrimaryKey[pKey] = new List<Part>(); // 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 Part
}
foreach (Part tmp in remove)
RemoveFromCache(tmp);
}
protected static Part GetCachedByPrimaryKey(int contentID, int fromType)
{