So I call this proc on EVERY turf on startup.
var/image/edge_image = image(icon = 'Edges6.dmi')
//check if a turf needs an "edge" and apply it as appropriate
GenerateEdges()
set waitfor=0
if(Water || density || !auto_edge || !edge_icon) return
var/list/ts = list(get_step(src,NORTH), get_step(src,EAST), get_step(src,WEST))
if(do_south_edge) ts += get_step(src,SOUTH)
for(var/turf/t in ts)
var/d = get_dir(src,t)
if(t.Water || (t.type == cliff_type && (d == EAST || d == WEST)))
switch(d)
if(NORTH)
edge_image.icon = edge_icon
edge_image.icon_state = "N"
overlays += edge_image
if(EAST)
edge_image.icon = edge_icon
edge_image.icon_state = "E"
overlays += edge_image
if(WEST)
edge_image.icon = edge_icon
edge_image.icon_state = "W"
overlays += edge_image
if(SOUTH)
if(do_south_edge && t.type != type)
edge_image.icon = edge_icon
edge_image.icon_state = "S"
overlays += edge_image
My question is how do I make it faster? It makes startup time ridiculously long. Thanks.
What are the slowest sections of this proc? I don't have much perspective on precisely where the slowdown primarily resides.
The proc itself could be caching the changes to edge_image, so further usage of that exact change to it wouldn't result in further appearance churn. So instead of changing edge_image.icon and edge_image.icon_state every time (which generates overhead), you'd store the first result of that in a list and reuse that in places where appropriate.