Quickest List Element Access
|
|
I'm storing a list of images so I can reuse them and don't have to recreate images to reduce lag/rending time. I'm wondering whats the best way to pull any image out of the list. I've tried var/image/img=imageresource[1] but it seems the list doesn't resize/reorganize fast enough for this to be viable, perhaps var/image/img=imageresource[imageresource.len]? or is var/image/img=locate(/image) in imageresource the best solution?
Code:
var/list/imageresource=new proc RecycleImage(var/image/img,time=0) set waitfor=FALSE sleep(time) img.transform=null img.pixel_x=null img.pixel_y=null img.color=null img.loc=null imageresource+=img FindImage() var/image/img=locate(/image) in imageresource//This part in particular is what I'm asking about if(img) imageresource-=img return img else return new/image
Problem description:
|
Also since speed is a concern for you, I would suggest using mutable appearances to reset your image instead of setting each var individually. You could keep a single mutable appearance and use it for all resets.