Skip to content

Commit 4af9d1e

Browse files
committed
#72 Initialize the eestatuses, lookingfor, indextable, and statuscode using make()
1 parent 441a908 commit 4af9d1e

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

smtp/status/find.go

+7-7
Original file line numberDiff line numberDiff line change
@@ -23,19 +23,19 @@ func Find(argv1 string, argv2 string) string {
2323
if len(argv2) < 1 { argv2 = " " }
2424

2525
givenclass := argv2[0:1]
26-
eestatuses := []string{}
26+
eestatuses := make([]string, 0, 3)
2727
esmtperror := " " + argv1 + " " // Why 3 space characters? see https://github.com/sisimai/p5-sisimai/issues/574
28-
lookingfor := map[string]string{}
29-
indextable := []int{}
28+
lookingfor := make(map[string]string, 10)
29+
indextable := make([]int, 0, 10)
3030
ip4address := rfc791.FindIPv4Address(&esmtperror)
3131

3232
if givenclass == "2" || givenclass == "4" || givenclass == "5" {
3333
// The second argument is a valid value
34-
eestatuses = []string{givenclass + "."}
34+
eestatuses = append(eestatuses, givenclass + ".")
3535

3636
} else {
3737
// The second argument has not been specified or an invalid value
38-
eestatuses = []string{"5.", "4.", "2."}
38+
eestatuses = append(eestatuses, []string{"5.", "4.", "2."}...)
3939
}
4040

4141
// Rewrite an IPv4 address in the given string(argv1) with '***.***.***.***'
@@ -54,8 +54,8 @@ func Find(argv1 string, argv2 string) string {
5454
}
5555
if len(lookingfor) == 0 { return "" }
5656

57-
statuscode := []string{} // List of SMTP Status Code, Keep the order of appearances
58-
anotherone := "" // Alternative code
57+
statuscode := make([]string, 0, 2) // List of SMTP Status Code, Keep the order of appearances
58+
anotherone := "" // Alternative code
5959
stringsize := len(esmtperror)
6060

6161
sort.Slice(indextable, func(a, b int) bool { return indextable[a] < indextable[b] })

0 commit comments

Comments
 (0)