···22222323<figure>
2424 <img
2525+ class="applerounded blackbg"
2526 width="1500"
2627 height="800"
2727- style="height: 20rem; width: auto; margin: 0 auto; display: block"
2828 alt="A screenshot of the Shortcuts app showing a basic procedure to search a website from an input."
2929 src="https://f004.backblazeb2.com/file/j0-lol-website/shortcutkagi.png"
3030 />
···3939</p>
40404141<img
4242+ class="superrounded blackbg"
4243 width="1284"
4344 height="116"
4445 alt="A screenshot of Spotlight showing a shortcut asking for input."
···54555556<figure>
5657 <img
5858+ class="applerounded blackbg"
5759 width="1500"
5860 height="800"
5959- style="height: 20rem; width: auto; margin: 0 auto; display: block"
6061 alt="A screenshot of the Shortcuts app with all the Spotlight shortcuts."
6162 src="https://f004.backblazeb2.com/file/j0-lol-website/spotlightshortcuts.png"
6263 />
+22-14
posts/swift-inline-array.html
···2424 and <code>InlineArray</code> is stack-allocated.
2525</p>
26262727-<pre><code class="language-swift">func array() {
2727+<pre><code class="language-swift"><!--
2828+func array() {
2829 var array = [4, 5, 6]
2930}
30313132func inlineArray() {
3232- var array: InlineArray<3, Int> = [4, 5, 6]
3333-}</code></pre>
3333+ var array: InlineArray<3, Int> = [4, 5, 6]
3434+}
3535+--></code></pre>
34363537And let's compare to Rust:
36383737-<pre><code class="language-rust">fn vec() {
3838- let mut vec = vec![4, 5, 6]; // I could wrap this in an Arc, but that's not really what real code would do.
3939+<pre><code class="language-rust">
4040+fn vec() {
4141+ // I could wrap this in an Arc, but
4242+ // that's not really what real code would do.
4343+ let mut vec = vec![4, 5, 6];
3944}
40454146fn array() {
4247 let mut arr = [4, 5, 6];
4343-}</code></pre>
4848+}
4949+</code></pre>
44504551<p>
4652 You can probably see the argument I'm going to make here — This is less
···5864</p>
59656066<figure>
6161- <pre><code class="language-swift">// Safe usage of a buffer pointer
6262-func processUsingBuffer(_ array: [Int]) -> Int {
6363- array.withUnsafeBufferPointer { buffer in
6464- var result = 0
6565- for i in 0..<buffer.count {
6666- result += calculate(using: buffer, at: i)
6767+ <pre><code class="language-swift">
6868+ // Safe usage of a buffer pointer
6969+ func processUsingBuffer(_ array: [Int]) -> Int {
7070+ array.withUnsafeBufferPointer { buffer in
7171+ var result = 0
7272+ for i in 0..<buffer.count {
7373+ result += calculate(using: buffer, at: i)
7474+ }
7575+ return result
6776 }
6868- return result
6977 }
7070-}</code></pre>
7878+ </code></pre>
71797280 <figcaption>Example from above WWDC talk, used as a reference.</figcaption>
7381</figure>