public static int unsignedLeb128Size(int value) {
    // TODO: This could be much cleverer.

    int remaining = value >> 7;
    int count = 0;

    while (remaining != 0) {
      remaining >>= 7;
      count++;
    }

    return count + 1;
  }
Gets the number of bytes in the unsigned LEB128 encoding of the given value.

@param value the value in question
@return its write size, in bytes
android/android_framework/dex-maker/src/main/java/com/android/dex/Leb128.java