ID:152190
 
After I started using text strings and findtext() to check for the tags of an turf to match my game's system, I just though of something and was wondering if it is more efficient/faster:
//#1
var/list/Admins=list("Kakashi24142")

//or...

//#2
var/admins="Kakashi24142;"

Couldn't I simply use findtext(admins,key) to check if a person is a valid Admin? I heard from reading Lummox Jr's Article on Green Programming that lists take up a lot of resources and should be avoided if not necessary(Correct me if I'm wrong) and would the text string be better than the list since all you're doing is checking for key names? To add/remove admins you could simply do: admins+="[target.key];"(if you're wondering what the semicolons are for, they are to separate each key so it it doesn't look like one big mumbo-jumbo.
That'll quite likely be slower, will take up much the same amount of memory (I think), but use one less list. If you're really running low on lists, maybe, but otherwise a single list won't cause you that many problems.
The question here seems more like how to handle limited text rather than limited lists. There is only one list, but think of all of the text stored inside of it. I'd use list2params() to store the list in one text var when it is not in use and then use params2list() when I actually want to mess with the contents.
Using the list will definitely be faster.

Using findtext() can possibly generate all sorts of problems in this case. For example, if you give someone with a key "Green Dragon" administrative abilities and someone walked in with key "Dragon", he'd get the powers as well.

Now, you could change it up a bit and use text2list() if you don't want to use a list all of the time. However, you sacrifice speed, only for a moment or two while you are checking to see if the user is an admin, to save on the list resources. Perhaps this method saves you speed while you aren't checking to see who is an admin.
In response to ACWraith
ACWraith wrote:
The question here seems more like how to handle limited text rather than limited lists. There is only one list, but think of all of the text stored inside of it. I'd use list2params() to store the list in one text var when it is not in use and then use params2list() when I actually want to mess with the contents.

... Which is what I would have said if I'd responded to this earlier. :P
In response to CaptFalcon33035
Using findtext() can possibly generate all sorts of problems in this case. For example, if you give someone with a key "Green Dragon" administrative abilities and someone walked in with key "Dragon", he'd get the powers as well.

that's why the admin string would be a character-delimited string instead of a concatenation of all admin names. for example, if your admins are named "bob", "tom", and "steve", the admin string would not be "bobtomsteve", but instead it would be "|bob|tom|steve|".

if you want to check if "eve" is an admin, you would search for the substring, "|eve|". while "eve" is a substring of the admin string, "|eve|" is not.

Using the list will definitely be faster.

sure, one of those methods has to be faster than the other, but does it matter? how often are you checking if someone is an admin? odds are that you aren't adding, removing, or checking admin status on a regular basis. one of those operations may happen once every few minutes.

if the operation takes 0.001 seconds and is done every 300 seconds, how much will your game speed up if you turn that 0.001 second operation into a 0.00097 second operation? its probably not worth your time to squeeze every last drop of optimization out of routines like this when you could make a very small optimization to a frequently used routine and make a much larger impact on the overall performance of your program.
In response to OneFishDown
Thanks for the help guys!
In response to Jp
The text string approach would probably use less memory, I think, as using a list uses a list object and multiple text strings for each new name added, while otherwise there is just a single fat text string.