title: SwiftUI Optimization
body: <p>The following code takes quiet some time to compile, I was wondering if someone could optimize it. I am new to SwiftUI, so please don't judge me for that code</p>
  <p>The following code generates a grid of VStacks(cells); I works, but it is slow and I don't want to have to wait that long and unoptimized code like this is generally not a good solution.</p>
  <p>The code compiles fast if I use fixed numbers inside the ForEach loop, but with my current setup it is slow...</p>
  <pre><code>let paletteColumns = 4 // The amount of columns
  let tmpCt = 18         // The amount of cells in total
  VStack {
      ForEach (0..&lt;(tmpCt / paletteColumns) + 1) {
          row in
          HStack {
              ForEach (0..&lt;min(tmpCt-(row * paletteColumns), paletteColumns)) {
                  col in
                  VStack {
                      // CODE FOR EACH CELL
                  }
              }
          }
       }
  }
  </code></pre>