<div dir="ltr">I'm trying to improve compile times in my project. I've been using "-Xfrontend -debug-time-function-bodies" to find to sore spots. Here's something that takes 1300ms to compile:<div><br></div><div><p style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(112,61,170)"><span style="color:rgb(187,44,162)">public</span><span style="color:rgb(0,0,0)"> </span><span style="color:rgb(187,44,162)">func</span><span style="color:rgb(0,0,0)"> ortho<T:</span>FloatingPointScalarType<span style="color:rgb(0,0,0)">></span></p>
<p style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo"> (left:<span style="color:rgb(112,61,170)">T</span>, <span style="color:rgb(187,44,162)">_</span> right:<span style="color:rgb(112,61,170)">T</span>, <span style="color:rgb(187,44,162)">_</span> bottom:<span style="color:rgb(112,61,170)">T</span>, <span style="color:rgb(187,44,162)">_</span> top:<span style="color:rgb(112,61,170)">T</span>) -> <span style="color:rgb(112,61,170)">Matrix4x4</span><<span style="color:rgb(79,129,135)">T</span>></p>
<p style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo">{</p>
<p style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo"> <span style="color:rgb(187,44,162)">let</span> t0:<span style="color:rgb(112,61,170)">T</span> = <span style="color:rgb(112,61,170)">T</span>(<span style="color:rgb(39,42,216)">0</span>)</p>
<p style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo"> <span style="color:rgb(187,44,162)">let</span> t1:<span style="color:rgb(112,61,170)">T</span> = <span style="color:rgb(112,61,170)">T</span>(<span style="color:rgb(39,42,216)">1</span>)</p>
<p style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo"> <span style="color:rgb(187,44,162)">let</span> t2:<span style="color:rgb(112,61,170)">T</span> = <span style="color:rgb(112,61,170)">T</span>(<span style="color:rgb(39,42,216)">2</span>)</p>
<p style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo;min-height:13px"><br></p>
<p style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo"> <span style="color:rgb(187,44,162)">let</span> r00:<span style="color:rgb(112,61,170)">T</span> = t2 / (right - left)</p>
<p style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo"> <span style="color:rgb(187,44,162)">let</span> r11:<span style="color:rgb(112,61,170)">T</span> = t2 / (top - bottom)</p>
<p style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo;min-height:13px"><br></p>
<p style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo"> <span style="color:rgb(187,44,162)">let</span> r30:<span style="color:rgb(112,61,170)">T</span> = -(right + left) / (right - left)</p>
<p style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo"> <span style="color:rgb(187,44,162)">let</span> r31:<span style="color:rgb(112,61,170)">T</span> = -(top + bottom) / (top - bottom)</p>
<p style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo;min-height:13px"><br></p>
<p style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo"> <span style="color:rgb(187,44,162)">return</span> Matrix4x4<<span style="color:rgb(79,129,135)">T</span>>(</p>
<p style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo"> r00, t0, t0, t0,</p>
<p style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo"> t0, r11, t0, t0,</p>
<p style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo"> t0, t0, -t1, t0,</p>
<p style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo"> r30, r31, t0, t1</p>
<p style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo"> )</p>
<p style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo">}</p></div><div><br></div><div>I'm not sure what to do from here. My program is unavoidably math heavy. Every new line of code adds about 60ms of compile time. And that's after I spend time typing in hints and splitting up the arithmetic.</div><div><br></div><div>-david <a href="https://github.com/AE9RB/SwiftGL">https://github.com/AE9RB/SwiftGL</a></div></div>