Fixes unnecessary multi-merge steps.

Changes merging from quadratic in the number of classes to linear.
This has a tremendous speed up while merging many dexes at the same time.
A sample test (iosched app) with 29 dexes goes from 6 seconds to 1.

Change-Id: Ie287bdb32b76ba06f362437b05f928bb7b528493
8 files changed