12
12
import me .gv7 .tools .josearcher .util .TypeUtils ;
13
13
import org .apache .log4j .Logger ;
14
14
import java .lang .reflect .Field ;
15
- import java .util .ArrayList ;
16
- import java .util .Iterator ;
17
- import java .util .List ;
18
- import java .util .Map ;
15
+ import java .util .*;
16
+
19
17
import static me .gv7 .tools .josearcher .util .Common .*;
20
18
import static me .gv7 .tools .josearcher .util .TypeUtils .*;
21
19
@@ -32,7 +30,7 @@ public class SearchRequstByRecursive {
32
30
private boolean is_debug = false ;
33
31
private String result_file ;
34
32
private String all_chain_file ;
35
- private List <Object > searched = new ArrayList < >();
33
+ private Set <Object > visited = new HashSet < Object >();
36
34
37
35
38
36
public SearchRequstByRecursive (Object target , List <Keyword > keys ){
@@ -73,18 +71,12 @@ private void searchObject(String filed_name,Object filed_object,String log_chain
73
71
}
74
72
75
73
//如果已经搜索过这个对象就返回不再继续搜索
76
- if (searched .size () <= 0 ){
77
- searched .add (filed_object );
78
- }else {
79
- for (Object obj : searched ) {
80
- if (obj == filed_object ) {
81
- return ;
82
- }
83
- }
84
- searched .add (filed_object );
74
+ if (!visited .contains (filed_object )) {
75
+ visited .add (filed_object );
76
+ }else {
77
+ return ;
85
78
}
86
79
87
-
88
80
String new_log_chain = "" ;
89
81
Class clazz = filed_object .getClass ();
90
82
0 commit comments