private void mergeTypeLists() {
    new IdMerger<TypeList>(typeListOut) {
      @Override
      TableOfContents.Section getSection(TableOfContents tableOfContents) {
        return tableOfContents.typeLists;
      }

      @Override
      TypeList read(Dex.Section in, IndexMap indexMap, int index) {
        return indexMap.adjustTypeList(in.readTypeList());
      }

      @Override
      void updateIndex(int offset, IndexMap indexMap, int oldIndex, int newIndex) {
        indexMap.putTypeListOffset(offset, typeListOut.getPosition());
      }

      @Override
      void write(TypeList value) {
        typeListOut.writeTypeList(value);
      }
    }.mergeUnsorted();
  }
minimum number of wasted bytes before it's worthwhile to compact the result
android/android_framework/dex-maker/src/main/java/com/android/dx/merge/DexMerger.java