private void cleanUpLabels() {
    int id = 0;
    for (Iterator<Label> i = labels.iterator(); i.hasNext(); ) {
      Label label = i.next();
      if (label.isEmpty()) {
        i.remove();
      } else {
        label.compact();
        label.id = id++;
      }
    }
  }
Removes empty labels and assigns IDs to non-empty labels.
android/android_framework/dex-maker/src/main/java/com/android/dx/Code.java