Tiny performance gains by preallocating arrays
@@ -996,7 +996,8 @@ func (window *Window) PopulateMentionWindowFromCurrentGuild(mentionWindow *tview
}
nameMap := make(map[string]string)
- var memberNames []string
+ //Preallocating the minimum size for a tiny performance boost.
+ memberNames := make([]string, 0, len(guild.Members))
for _, user := range guild.Members {
userName := user.User.Username + "#" + user.User.Discriminator
if len(user.Nick) > 0 {
@@ -1049,7 +1050,7 @@ func (window *Window) addNodeToMentionWindow(mentionWindow *tview.TreeView, name
}
func (window *Window) PopulateMentionWindowFromCurrentChannel(mentionWindow *tview.TreeView, namePart string) {
- var memberNames []string
+ memberNames := make([]string, 0, len(window.selectedChannel.Recipients))
for _, user := range window.selectedChannel.Recipients {
userName := user.Username + "#" + user.Discriminator
memberNames = append(memberNames, userName)
