-
Notifications
You must be signed in to change notification settings - Fork 72
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Optimize element lookup in FileSystemFinder by switching from []strin…
…g to map[string]struct{} (#115) * changed []string to map[string]struct{} in FileSystemFinder struct fields because of optimization (arrays were used only to check the occurrence of an element) * Changed field Extensions type in FileType from []string to map[string]struct{} * added requested changes --------- Co-authored-by: Yaroslav <=>
- Loading branch information
1 parent
b48fa22
commit c824e2a
Showing
4 changed files
with
41 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package misc | ||
|
||
// ArrToMap converts a string array | ||
// to a map with keys from the array | ||
// and empty struct values, optimizing string presence checks. | ||
func ArrToMap(arg ...string) map[string]struct{} { | ||
m := make(map[string]struct{}, 0) | ||
for _, item := range arg { | ||
m[item] = struct{}{} | ||
} | ||
return m | ||
} |