private void addOrUpdateEnd(int address, Disposition disposition, RegisterSpec spec) {
      if (disposition == Disposition.START) {
        throw new RuntimeException("shouldn't happen");
      }

      int regNum = spec.getReg();
      int endAt = endIndices[regNum];

      if (endAt >= 0) {
        // There is a previous end.
        Entry endEntry = result.get(endAt);
        if ((endEntry.getAddress() == address) && endEntry.getRegisterSpec().equals(spec)) {
          /*
           * The end is for the right address and variable, so
           * update it.
           */
          result.set(endAt, endEntry.withDisposition(disposition));
          regs.remove(spec); // TODO: Is this line superfluous?
          return;
        }
      }

      endLocal(address, spec, disposition);
    }
Adds or updates an end local (changing its disposition). If this would cause an empty range
for a local, this instead removes the local entirely.

@param address {@code >= 0;} the address
@param disposition {@code non-null;} the disposition
@param spec {@code non-null;} spec representing the local
android/android_framework/dex-maker/src/main/java/com/android/dx/dex/code/LocalList.java