mob/var/list/L
is there a difference between doing this -
mob/proc/blah()
L+="Blah"
or this
mob/proc/blah()
L.Add("Blah")
I have a few more questions about lists if anyone is willing to help me understand... things about proficiency and such!
ID:267792
Oct 14 2003, 4:56 pm
|
|
This question interested me and got my curiosity up when I saw it. So I stopped right there and opened dream seeker to do some tests. After doing some major list appending (Each test would append to a list 655350 times with either the += operator or the Add() function) and clocking the speeds for each, I have figured that Add() takes approximately 1.5 times longer than +=.
|
In response to Loduwijk
|
|
Loduwijk wrote:
This question interested me and got my curiosity up when I saw it. So I stopped right there and opened dream seeker to do some tests. After doing some major list appending (Each test would append to a list 655350 times with either the += operator or the Add() function) and clocking the speeds for each, I have figured that Add() takes approximately 1.5 times longer than +=. Interesting. I'd guess this is because of the overhead from dealing with a proc call. Good to have this settled. Lummox JR |
In response to Loduwijk
|
|
Loduwijk wrote:
This question interested me and got my curiosity up when I saw it. So I stopped right there and opened dream seeker to do some tests. After doing some major list appending (Each test would append to a list 655350 times with either the += operator or the Add() function) and clocking the speeds for each, I have figured that Add() takes approximately 1.5 times longer than +=. Isn't the default procedure of Add() simply using the += operator? |
In response to Lummox JR
|
|
what about
mob/var/list/L or mob/var/L=newlist() or mob/var/L[] which is more affective? is there a difference? I just noticed that there's several ways to declare a list... since I'm dealing with heavy amounts of lists... another thing is... how would I do this - Have 4 different "txt strings" in the list, but each one is a unique individual txt string, so that I can call the list from var/r=input("Which one in list") in list(src.L) one way I know to do this is just to create the list in the procedure... then just do L+="blah" then hit enter/tab and do it again... I was wondering if you could call the "blah" or text strings during creation of that mob... would it be efficient to do so or would this just consume resources? Especially when saving? mob/var/list/L=("blah","blah","blah","blah") |
In response to Jon Snow
|
|
Jon Snow wrote:
what about Actually newlist() is entirely the wrong choice for this case; you'd be better off with list(). My guess is, no, there isn't much of a difference between these. But if there is, you'd have a heck of a time trying to test it. I just noticed that there's several ways to declare a list... This sets up a default list for all mobs, so that if you don't change the value of L, it defaults to that list. The default list can be changed by any mob, so if what you're going for is a way to pool data, that's what you need. But if the list is to be individual, you're better off initializing it in New() or when you need it. Lummox JR |
In response to Lummox JR
|
|
thanks a ton lummox!
Now lets hope I can manage to not make my game super laggy lol... |
In response to Jon Snow
|
|
Click()
var/list/L() L+="Cancel" L+="Go on" L+="sigh, only if I have to" var/t=input(usr,"What do you wish to research/develop?") in list(L) if(t=="Cancel") return Ok the problem here is even though I added "Cancel" to L, it will not give me a list with cancel or Go on in it... how would I go about doin this? |
In response to Jon Snow
|
|
Do var/list/L=list() instead of var/list/L(), that might help a bit. If you want to create a list without the "=list()" then do var/L[].
|
Lummox JR