code: static int[] compactOffsets(int[] offsets, int index, int length)
      {
          if (index == 0 && offsets.length == length + 1) {
              return offsets;
          }
  
          int[] newOffsets = new int[length + 1];
          for (int i = 1; i <= length; i++) {
              newOffsets[i] = offsets[index + i] - offsets[index];
          }
          return newOffsets;
      }
docs: Recalculate the <code>offsets</code> array for the specified range.
  The returned <code>offsets</code> array contains <code>length + 1</code> integers
  with the first value set to 0.
  If the range matches the entire <code>offsets</code> array,  the input array will be returned.