Optimises uniqueList()

Credits go to /TG/, I just figured I'd do what the other codebases do and take it over for us as well.

Changes:

Optimises uniquelist()
also renames it from uniquelist() to uniqueList()
Test 1:

1,000,000 random numbers between 1 and 7 in a list.
Clean out duplicates with current uniquelist(), once:
self: 0.362
Clean out duplicates with my new uniqueList(), once:
self: 0.184

Test 2:

3,000,000 random numbers between 1 and 7 in a list.
Clean out duplicates with current uniquelist(), once:
self: 1.069
Clean out duplicates with my new uniqueList(), once:
self: 0.496
This commit is contained in:
StarSmasher
2015-05-10 16:59:32 +02:00
parent 6e003e6d99
commit 09b92c347f
+3 -5
View File
@@ -182,11 +182,9 @@ proc/listclearnulls(list/list)
//Return a list with no duplicate entries
/proc/uniquelist(var/list/L)
var/list/K = list()
for(var/item in L)
if(!(item in K))
K += item
return K
. = list()
for(var/i in L)
. |= i
//Mergesort: divides up the list into halves to begin the sort
/proc/sortKey(var/list/client/L, var/order = 1)