about summary refs log tree commit diff
diff options
context:
space:
mode:
authoroy <Tom_Adams@web.de>2011-03-27 16:42:47 +0200
committeroy <Tom_Adams@web.de>2011-03-27 16:42:47 +0200
commit4d5443affa2cccfbf84afbd3790dcc105e5edef0 (patch)
treec6b723c5c4749b73eaf8e69b6158c1306fb96a35
parent2aa1bda97ef8423ff070911bac09b0fb36a35e02 (diff)
downloadzcatch-4d5443affa2cccfbf84afbd3790dcc105e5edef0.tar.gz
zcatch-4d5443affa2cccfbf84afbd3790dcc105e5edef0.zip
added demo loading speed enhancement by MAP94. Closes #555
-rw-r--r--src/base/tl/array.h3
-rw-r--r--src/base/tl/sorted_array.h11
-rw-r--r--src/game/client/components/menus_demo.cpp3
3 files changed, 15 insertions, 2 deletions
diff --git a/src/base/tl/array.h b/src/base/tl/array.h
index ebc276fc..6aff3c71 100644
--- a/src/base/tl/array.h
+++ b/src/base/tl/array.h
@@ -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;
 	}
 
diff --git a/src/base/tl/sorted_array.h b/src/base/tl/sorted_array.h
index 7ca7ff8d..7c45cf28 100644
--- a/src/base/tl/sorted_array.h
+++ b/src/base/tl/sorted_array.h
@@ -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.
diff --git a/src/game/client/components/menus_demo.cpp b/src/game/client/components/menus_demo.cpp
index 3d359178..94b315d7 100644
--- a/src/game/client/components/menus_demo.cpp
+++ b/src/game/client/components/menus_demo.cpp
@@ -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)