Skip to content

Commit

Permalink
优化查询叶子继承
Browse files Browse the repository at this point in the history
  • Loading branch information
FlyJingFish committed Dec 12, 2023
1 parent b8853f6 commit 3c9fe27
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 14 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.flyjingfish.android_aop_plugin.beans

class ClassSuperInfo(val className: String, val superName: String, val interfaces: ArrayList<String>) {
class ClassSuperInfo(val className: String, val superName: String?, val interfaces: Array<String>?) {
}
Original file line number Diff line number Diff line change
@@ -1,15 +1,10 @@
package com.flyjingfish.android_aop_plugin.scanner_visitor;

import com.flyjingfish.android_aop_plugin.beans.ClassSuperInfo;
import com.flyjingfish.android_aop_plugin.utils.UtilsKt;
import com.flyjingfish.android_aop_plugin.utils.WovenInfoUtils;

import org.objectweb.asm.ClassVisitor;
import org.objectweb.asm.Opcodes;
import org.slf4j.Logger;

import java.util.ArrayList;
import java.util.Arrays;

public class ClassSuperScanner extends ClassVisitor {
public ClassSuperScanner() {
Expand All @@ -19,12 +14,6 @@ public ClassSuperScanner() {
@Override
public void visit(int version, int access, String name, String signature, String superName, String[] interfaces) {
super.visit(version, access, name, signature, superName, interfaces);
ArrayList<String> interfaceList;
if (interfaces == null){
interfaceList = new ArrayList<>();
}else {
interfaceList = new ArrayList<>(Arrays.asList(interfaces));
}
WovenInfoUtils.INSTANCE.addClassSuper(new ClassSuperInfo(name,superName,interfaceList));
WovenInfoUtils.INSTANCE.addClassSuper(new ClassSuperInfo(name,superName,interfaces));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ object WovenInfoUtils {

fun isLeaf(className:String):Boolean{
for (classSuperInfo in classSuperList) {
if (classSuperInfo.superName == className || (classSuperInfo.interfaces.contains(className))){
if (classSuperInfo.superName == className || (classSuperInfo.interfaces?.contains(className) == true)){
return false
}
}
Expand Down

0 comments on commit 3c9fe27

Please sign in to comment.