refactor: use same instance for empty type vars annotation
This commit is contained in:
@@ -1,19 +1,30 @@
|
||||
package jadx.core.dex.attributes.nodes;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.Set;
|
||||
|
||||
import jadx.core.dex.attributes.AType;
|
||||
import jadx.core.dex.attributes.IAttribute;
|
||||
import jadx.core.dex.instructions.args.ArgType;
|
||||
|
||||
import static jadx.core.utils.Utils.isEmpty;
|
||||
|
||||
/**
|
||||
* Set of known type variables at current method
|
||||
*/
|
||||
public class MethodTypeVarsAttr implements IAttribute {
|
||||
private static final MethodTypeVarsAttr EMPTY = new MethodTypeVarsAttr(Collections.emptySet());
|
||||
|
||||
public static MethodTypeVarsAttr build(Set<ArgType> typeVars) {
|
||||
if (isEmpty(typeVars)) {
|
||||
return EMPTY;
|
||||
}
|
||||
return new MethodTypeVarsAttr(typeVars);
|
||||
}
|
||||
|
||||
private final Set<ArgType> typeVars;
|
||||
|
||||
public MethodTypeVarsAttr(Set<ArgType> typeVars) {
|
||||
private MethodTypeVarsAttr(Set<ArgType> typeVars) {
|
||||
this.typeVars = typeVars;
|
||||
}
|
||||
|
||||
|
||||
@@ -92,8 +92,9 @@ public class TypeUtils {
|
||||
return typeVarsAttr.getTypeVars();
|
||||
}
|
||||
Set<ArgType> typeVars = collectKnownTypeVarsAtMethod(mth);
|
||||
mth.addAttr(new MethodTypeVarsAttr(typeVars));
|
||||
return typeVars;
|
||||
MethodTypeVarsAttr varsAttr = MethodTypeVarsAttr.build(typeVars);
|
||||
mth.addAttr(varsAttr);
|
||||
return varsAttr.getTypeVars();
|
||||
}
|
||||
|
||||
private static Set<ArgType> collectKnownTypeVarsAtMethod(MethodNode mth) {
|
||||
|
||||
Reference in New Issue
Block a user