layer_line: move conditional function in-line