title: What would be more efficient for speed modulo or if statement?
body: <p>Which would would be better the fastest solution to wrap an index around a range  if im calling the code many times in a loop?</p>
  
  <pre><code>int length = 4;
  int firstIndex = 4;
  int lastIndex = 7;
  int currIndex = 4;
  
  // Example 1 (if statement)
      // Incrementing currIndex
          if (++currIndex &gt; lastIndex)
              currIndex = firstIndex;
      // Decrementing currIndex
          if (--currIndex &lt; firstIndex)
              currIndex = lastIndex
  
  // Example 2 (Modulo)
      // Incrementing currIndex
          currIndex = firstIndex + (++currIndex % length);
      // Decrementing currIndex
          currIndex = firstIndex + ((--currIndex + length) % length);
  </code></pre>