First filtering for static fields, then sorting them. Using filtered list in a Key. Removed deprecated guava methods.

This commit is contained in:
Izzat Bahadirov 2013-03-29 20:14:27 -04:00
parent 0e56199557
commit 1d4b31a11c

View File

@ -140,13 +140,12 @@ public class EncodedArrayPool {
@Nullable @Nullable
public static Key of(@Nonnull ClassDef classDef) { public static Key of(@Nonnull ClassDef classDef) {
Set<? extends Field> fields = FluentIterable.from(classDef.getFields()).toImmutableSortedSet(new FieldComparator()); Set<? extends Field> staticFields = FluentIterable.from(classDef.getFields()).filter(IS_STATIC_FIELD).toSet();
Iterable<? extends Field> staticFieldsSorted = FluentIterable.from(staticFields).toSortedSet(new FieldComparator());
Iterable<? extends Field> staticFields = FluentIterable.from(fields).filter(IS_STATIC_FIELD);
int lastIndex = CollectionUtils.lastIndexOf(staticFields, HAS_INITIALIZER);
int lastIndex = CollectionUtils.lastIndexOf(staticFieldsSorted, HAS_INITIALIZER);
if (lastIndex > -1) { if (lastIndex > -1) {
return new Key(fields, lastIndex+1); return new Key(staticFields, lastIndex+1);
} }
return null; return null;
} }
@ -158,7 +157,6 @@ public class EncodedArrayPool {
@Nonnull @Nonnull
public Iterable<EncodedValue> getElements() { public Iterable<EncodedValue> getElements() {
return FluentIterable.from(fields) return FluentIterable.from(fields)
.filter(IS_STATIC_FIELD)
.limit(size) .limit(size)
.transform(GET_INITIAL_VALUE); .transform(GET_INITIAL_VALUE);
} }