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: Iff02a0dc44d098b0878e88d18f5f4083804a6495
8 files changed