for(var/mob/M in world)//or
for(var/obj/O in world)
And now that I plan to reduce lag on my games I heard that this is a bad way to use for... However I researched in forums and fount other ppl saying the same thing but no solution..
I fount out that this works the same way:
for(var/mob/M)//or
for(var/obj/O)
But I dont know if there are any diffrence...
if both are really the same, should I try to make another way to loop through mob/obj? Like creating a list and adding them at new() would Be better then both options?
Yes. Adding only the objects that you need to a list, assuming that list will be smaller than all objects in the world, will always be more efficient than cycling through every single object in the world. If you'll end up needing every object in the world anyway, though, you'd probably be better off just looping through all of them with for(). Although, I hope that's not the case and that you can narrow down which ones you need in a list.