mirror of
https://github.com/VOREStation/VOREStation.git
synced 2026-08-25 04:57:47 +01:00
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:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user