@@ -44,18 +44,13 @@ func ResolveLibrary(ctx *types.Context, header string) *types.Library {
44
44
libraryResolutionResults := ctx .LibrariesResolutionResults
45
45
importedLibraries := ctx .ImportedLibraries
46
46
47
- markImportedLibrary := make (map [* types.Library ]bool )
48
- for _ , library := range importedLibraries {
49
- markImportedLibrary [library ] = true
50
- }
51
-
52
47
libraries := append ([]* types.Library {}, headerToLibraries [header ]... )
53
48
54
49
if libraries == nil || len (libraries ) == 0 {
55
50
return nil
56
51
}
57
52
58
- if markImportedLibraryContainsOneOfCandidates ( markImportedLibrary , libraries ) {
53
+ if importedLibraryContainsOneOfCandidates ( importedLibraries , libraries ) {
59
54
return nil
60
55
}
61
56
@@ -87,7 +82,7 @@ func ResolveLibrary(ctx *types.Context, header string) *types.Library {
87
82
library = libraries [0 ]
88
83
}
89
84
90
- library = useAlreadyImportedLibraryWithSameNameIfExists (library , markImportedLibrary )
85
+ library = useAlreadyImportedLibraryWithSameNameIfExists (library , importedLibraries )
91
86
92
87
libraryResolutionResults [header ] = types.LibraryResolutionResult {Library : library , NotUsedLibraries : filterOutLibraryFrom (libraries , library )}
93
88
@@ -101,19 +96,19 @@ func reverse(data []*types.Library) {
101
96
}
102
97
}
103
98
104
- func markImportedLibraryContainsOneOfCandidates ( markImportedLibrary map [ * types.Library ] bool , libraries []* types.Library ) bool {
105
- for markedLibrary , _ := range markImportedLibrary {
106
- for _ , library := range libraries {
107
- if markedLibrary == library {
99
+ func importedLibraryContainsOneOfCandidates ( imported [] * types.Library , candidates []* types.Library ) bool {
100
+ for _ , i := range imported {
101
+ for _ , j := range candidates {
102
+ if i == j {
108
103
return true
109
104
}
110
105
}
111
106
}
112
107
return false
113
108
}
114
109
115
- func useAlreadyImportedLibraryWithSameNameIfExists (library * types.Library , markImportedLibrary map [ * types.Library ] bool ) * types.Library {
116
- for lib , _ := range markImportedLibrary {
110
+ func useAlreadyImportedLibraryWithSameNameIfExists (library * types.Library , imported [] * types.Library ) * types.Library {
111
+ for _ , lib := range imported {
117
112
if lib .Name == library .Name {
118
113
return lib
119
114
}
0 commit comments