From 4de8efcc31f02ee8d30df33c62cd24005f5f584f Mon Sep 17 00:00:00 2001 From: Ben Gruver Date: Mon, 11 Jun 2012 16:00:43 -0700 Subject: [PATCH] Don't pre-sort ClassDefItems --- dexlib/src/main/java/org/jf/dexlib/ClassDefItem.java | 6 +++--- dexlib/src/main/java/org/jf/dexlib/DexFile.java | 11 +++++------ 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/dexlib/src/main/java/org/jf/dexlib/ClassDefItem.java b/dexlib/src/main/java/org/jf/dexlib/ClassDefItem.java index 3c9638dd..a1942313 100644 --- a/dexlib/src/main/java/org/jf/dexlib/ClassDefItem.java +++ b/dexlib/src/main/java/org/jf/dexlib/ClassDefItem.java @@ -197,9 +197,9 @@ public class ClassDefItem extends Item { /** {@inheritDoc} */ public int compareTo(ClassDefItem o) { - //The actual sorting for this class is implemented in SortClassDefItemSection. - //This method is just used for sorting the associated ClassDataItem items, so - //we can just do the comparison based on the offsets of the items + //The actual sorting for this class is done during the placement phase, in ClassDefPlacer. + //This method is just used for sorting the associated ClassDataItem items after the ClassDefItems have been + //placed, so we can just do the comparison based on the offsets return this.getOffset() - o.getOffset(); } diff --git a/dexlib/src/main/java/org/jf/dexlib/DexFile.java b/dexlib/src/main/java/org/jf/dexlib/DexFile.java index a31ee666..80f25f87 100644 --- a/dexlib/src/main/java/org/jf/dexlib/DexFile.java +++ b/dexlib/src/main/java/org/jf/dexlib/DexFile.java @@ -773,16 +773,15 @@ public class DexFile int ret = ClassDefItem.placeClassDefItems(this, offset); - Collections.sort(this.items, new Comparator() { - - public int compare(ClassDefItem a, ClassDefItem b) { - return a.getOffset() - b.getOffset(); - } - }); + Collections.sort(this.items); this.offset = items.get(0).getOffset(); return ret; } + + protected void sortSection() { + // Do nothing. Sorting is handled by ClassDefItem.ClassDefPlacer, during placement + } }; /**