title: How would I rewrite the for statements in this function to be more performant?
body: <p>I have the following function:</p>
  <pre><code>ColorPalette._processPaletteImageData = function() {
      const paletteImage = this._bmp();
      const source = this._source;
      if (paletteImage) {
          const _colorPicker = (_n) =&gt; {
              const pX = source.offsetX + (_n % 8) * 12 + 6;
              const pY = source.offsetY + Math.floor(_n / 8) * 12 + 6;
              return paletteImage.getPixel(pX, pY);
          };
          const _toRgba = (_o) =&gt; {return [_o.r, _o.g, _o.b, _o.a]};
          const dataDivisions = source.dataDivisions;
          const splits = (dataDivisions.length - 1);
          let tally = 0;
          for (let i = 0; i &lt;= splits; i++) {
              this._data[i] = {};
              const colors = (dataDivisions[i] - 1);
              for (let j = 0; j &lt;= colors; j++) {
                  const position = tally + j;
                  const hex = _colorPicker(position);
                  const color = tinycolor(hex);
                  const rgba = _toRgba(color.toRgb());
                  const score = Utils.computeColorScore(rgba);
                  const [colorName, shade] = Utils.hexToColorName(hex).split(DIVISION);
                  const inverse = Utils.invertColor(hex, false);
                  const complement = color.complement().toHexString();
                  this._data[i][colorName] = {
                      &quot;hex&quot;: hex,
                      &quot;compliment&quot;: complement,
                      &quot;inverse&quot;: inverse,
                      &quot;rgba&quot;: rgba,
                      &quot;score&quot;: score,
                      &quot;shade&quot;: shade,
                  };
              };
              tally += colors + 1;
          };
      };
  };
  </code></pre>
  <p>There are two for statements in the aforementioned code:</p>
  <ol>
  <li><code>for (let i = 0; i &lt;= splits; i++)</code></li>
  <li><code>for (let j = 0; j &lt;= colors; j++)</code></li>
  </ol>
  <p>How would I rewrite the function so that the For statements look like:</p>
  <ol>
  <li><code>for (let i = splits; i &gt;= 0; i--)</code></li>
  <li><code>for (let j = colors; j &gt;= 0; j--)</code></li>
  </ol>