added demo loading speed enhancement by MAP94. Closes #555

This commit is contained in:
oy 2011-03-27 16:42:47 +02:00
parent 2aa1bda97e
commit 4d5443affa
3 changed files with 15 additions and 2 deletions

View file

@ -242,7 +242,8 @@ public:
*/
void set_size(int new_size)
{
alloc(new_size);
if(list_size < new_size)
alloc(new_size);
num_elements = new_size;
}

View file

@ -23,6 +23,17 @@ public:
return parent::insert(item, partition_binary(all(), item));
}
int add_unsorted(const T& item)
{
return parent::add(item);
}
void sort_range()
{
sort(all());
}
/*
Function: all
Returns a sorted range that contains the whole array.

View file

@ -457,7 +457,7 @@ int CMenus::DemolistFetchCallback(const char *pName, int IsDir, int StorageType,
}
Item.m_IsDir = IsDir != 0;
Item.m_StorageType = StorageType;
pSelf->m_lDemos.add(Item);
pSelf->m_lDemos.add_unsorted(Item);
return 0;
}
@ -468,6 +468,7 @@ void CMenus::DemolistPopulate()
if(!str_comp(m_aCurrentDemoFolder, "demos"))
m_DemolistStorageType = IStorage::TYPE_ALL;
Storage()->ListDirectory(m_DemolistStorageType, m_aCurrentDemoFolder, DemolistFetchCallback, this);
m_lDemos.sort_range();
}
void CMenus::DemolistOnUpdate(bool Reset)