mirror of
https://github.com/revanced/smali.git
synced 2025-05-29 12:20:11 +02:00
Don't write out 0-length type lists
This commit is contained in:
parent
f6958ae4bc
commit
08d90ec360
@ -55,7 +55,7 @@ class BuilderTypeListPool implements TypeListSection<BuilderTypeReference, Build
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Nonnull public BuilderTypeList internTypeList(@Nullable List<? extends CharSequence> types) {
|
@Nonnull public BuilderTypeList internTypeList(@Nullable List<? extends CharSequence> types) {
|
||||||
if (types == null) {
|
if (types == null || types.size() == 0) {
|
||||||
return BuilderTypeList.EMPTY;
|
return BuilderTypeList.EMPTY;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -76,7 +76,7 @@ class BuilderTypeListPool implements TypeListSection<BuilderTypeReference, Build
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override public int getNullableItemOffset(@Nullable BuilderTypeList key) {
|
@Override public int getNullableItemOffset(@Nullable BuilderTypeList key) {
|
||||||
return key==null?DexWriter.NO_OFFSET:key.offset;
|
return (key==null||key.size()==0)?DexWriter.NO_OFFSET:key.offset;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nonnull @Override
|
@Nonnull @Override
|
||||||
|
@ -32,10 +32,12 @@
|
|||||||
package org.jf.dexlib2.writer.pool;
|
package org.jf.dexlib2.writer.pool;
|
||||||
|
|
||||||
import com.google.common.collect.ImmutableList;
|
import com.google.common.collect.ImmutableList;
|
||||||
import org.jf.dexlib2.writer.pool.TypeListPool.Key;
|
import org.jf.dexlib2.writer.DexWriter;
|
||||||
import org.jf.dexlib2.writer.TypeListSection;
|
import org.jf.dexlib2.writer.TypeListSection;
|
||||||
|
import org.jf.dexlib2.writer.pool.TypeListPool.Key;
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
import javax.annotation.Nonnull;
|
||||||
|
import javax.annotation.Nullable;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
|
|
||||||
@ -48,11 +50,13 @@ public class TypeListPool extends BaseNullableOffsetPool<Key<? extends Collectio
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void intern(@Nonnull Collection<? extends CharSequence> types) {
|
public void intern(@Nonnull Collection<? extends CharSequence> types) {
|
||||||
Key<? extends Collection<? extends CharSequence>> key = new Key<Collection<? extends CharSequence>>(types);
|
if (types.size() > 0) {
|
||||||
Integer prev = internedItems.put(key, 0);
|
Key<? extends Collection<? extends CharSequence>> key = new Key<Collection<? extends CharSequence>>(types);
|
||||||
if (prev == null) {
|
Integer prev = internedItems.put(key, 0);
|
||||||
for (CharSequence type: types) {
|
if (prev == null) {
|
||||||
typePool.intern(type);
|
for (CharSequence type: types) {
|
||||||
|
typePool.intern(type);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -65,6 +69,14 @@ public class TypeListPool extends BaseNullableOffsetPool<Key<? extends Collectio
|
|||||||
return typesKey.types;
|
return typesKey.types;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override public int getNullableItemOffset(@Nullable Key<? extends Collection<? extends CharSequence>> key) {
|
||||||
|
if (key == null || key.types.size() == 0) {
|
||||||
|
return DexWriter.NO_OFFSET;
|
||||||
|
} else {
|
||||||
|
return super.getNullableItemOffset(key);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public static class Key<TypeCollection extends Collection<? extends CharSequence>>
|
public static class Key<TypeCollection extends Collection<? extends CharSequence>>
|
||||||
implements Comparable<Key<? extends Collection<? extends CharSequence>>> {
|
implements Comparable<Key<? extends Collection<? extends CharSequence>>> {
|
||||||
@Nonnull TypeCollection types;
|
@Nonnull TypeCollection types;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user