private static boolean shouldPack(IntList cases) {
    int sz = cases.size();

    if (sz < 2) {
      return true;
    }

    long packedSize = packedCodeSize(cases);
    long sparseSize = sparseCodeSize(cases);

    /*
     * We pick the packed representation if it is possible and
     * would be as small or smaller than 5/4 of the sparse
     * representation. That is, we accept some size overhead on
     * the packed representation, since that format is faster to
     * execute at runtime.
     */
    return (packedSize >= 0) && (packedSize <= ((sparseSize * 5) / 4));
  }
Determines whether the given list of cases warrant being packed.

@param cases {@code non-null;} sorted list of cases
@return {@code true} iff the table encoding the cases should be packed
android/android_framework/dex-maker/src/main/java/com/android/dx/dex/code/SwitchData.java