mirror of
https://github.com/taigrr/wtf
synced 2025-01-18 04:03:14 -08:00
Preallocate slice
This commit is contained in:
parent
ca18a14d43
commit
5b4a49d11f
@ -25,10 +25,10 @@ func NameFromEmail(email string) string {
|
|||||||
// > []string{"Test_user", "Other_user"}
|
// > []string{"Test_user", "Other_user"}
|
||||||
//
|
//
|
||||||
func NamesFromEmails(emails []string) []string {
|
func NamesFromEmails(emails []string) []string {
|
||||||
names := []string{}
|
names := make([]string, len(emails))
|
||||||
|
|
||||||
for _, email := range emails {
|
for i, email := range emails {
|
||||||
names = append(names, NameFromEmail(email))
|
names[i] = NameFromEmail(email)
|
||||||
}
|
}
|
||||||
|
|
||||||
return names
|
return names
|
||||||
|
Loading…
x
Reference in New Issue
Block a user