From 1d4b31a11cc0943bf33018c51f36441c7bad47e3 Mon Sep 17 00:00:00 2001 From: Izzat Bahadirov Date: Fri, 29 Mar 2013 20:14:27 -0400 Subject: [PATCH] First filtering for static fields, then sorting them. Using filtered list in a Key. Removed deprecated guava methods. --- .../java/org/jf/dexlib2/writer/EncodedArrayPool.java | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/dexlib2/src/main/java/org/jf/dexlib2/writer/EncodedArrayPool.java b/dexlib2/src/main/java/org/jf/dexlib2/writer/EncodedArrayPool.java index 39c7547c..ae6d4ebb 100644 --- a/dexlib2/src/main/java/org/jf/dexlib2/writer/EncodedArrayPool.java +++ b/dexlib2/src/main/java/org/jf/dexlib2/writer/EncodedArrayPool.java @@ -140,13 +140,12 @@ public class EncodedArrayPool { @Nullable public static Key of(@Nonnull ClassDef classDef) { - Set fields = FluentIterable.from(classDef.getFields()).toImmutableSortedSet(new FieldComparator()); - - Iterable staticFields = FluentIterable.from(fields).filter(IS_STATIC_FIELD); - int lastIndex = CollectionUtils.lastIndexOf(staticFields, HAS_INITIALIZER); + Set staticFields = FluentIterable.from(classDef.getFields()).filter(IS_STATIC_FIELD).toSet(); + Iterable staticFieldsSorted = FluentIterable.from(staticFields).toSortedSet(new FieldComparator()); + int lastIndex = CollectionUtils.lastIndexOf(staticFieldsSorted, HAS_INITIALIZER); if (lastIndex > -1) { - return new Key(fields, lastIndex+1); + return new Key(staticFields, lastIndex+1); } return null; } @@ -158,7 +157,6 @@ public class EncodedArrayPool { @Nonnull public Iterable getElements() { return FluentIterable.from(fields) - .filter(IS_STATIC_FIELD) .limit(size) .transform(GET_INITIAL_VALUE); }