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