diff --git a/code/game/atoms_movable.dm b/code/game/atoms_movable.dm index a46d34a3b26..235c008d233 100644 --- a/code/game/atoms_movable.dm +++ b/code/game/atoms_movable.dm @@ -225,15 +225,23 @@ vis_contents.Cut() /atom/movable/proc/update_emissive_block() - if(!blocks_emissive) - return - else if (blocks_emissive == EMISSIVE_BLOCK_GENERIC) + // This one is incredible. + // `if (x) else { /* code */ }` is surprisingly fast, and it's faster than a switch, which is seemingly not a jump table. + // From what I can tell, a switch case checks every single branch individually, although sane, is slow in a hot proc like this. + // So, we make the most common `blocks_emissive` value, EMISSIVE_BLOCK_GENERIC, 0, getting to the fast else branch quickly. + // If it fails, then we can check over every value it can be (here, EMISSIVE_BLOCK_UNIQUE is the only one that matters). + // This saves several hundred milliseconds of init time. + if (blocks_emissive) + if (blocks_emissive == EMISSIVE_BLOCK_UNIQUE) + if(!em_block && !QDELETED(src)) + render_target = ref(src) + em_block = new(src, render_target) + return em_block + // Implied else if (blocks_emissive == EMISSIVE_BLOCK_NONE) -> return + // EMISSIVE_BLOCK_GENERIC == 0 + else return fast_emissive_blocker(src) - else if(blocks_emissive == EMISSIVE_BLOCK_UNIQUE) - if(!em_block && !QDELETED(src)) - render_target = ref(src) - em_block = new(src, render_target) - return em_block + /// Generates a space underlay for a turf /// This provides proper lighting support alongside just looking nice diff --git a/code/modules/atmospherics/machinery/pipes/pipes.dm b/code/modules/atmospherics/machinery/pipes/pipes.dm index de745df7e5f..df4884d0c06 100644 --- a/code/modules/atmospherics/machinery/pipes/pipes.dm +++ b/code/modules/atmospherics/machinery/pipes/pipes.dm @@ -105,9 +105,9 @@ icon_state = "[bitfield]_[piping_layer]" /obj/machinery/atmospherics/pipe/update_icon() - . = ..() update_pipe_icon() update_layer() + return ..() /obj/machinery/atmospherics/proc/update_node_icon() for(var/i in 1 to device_type)