perf: preallocate array capacity

This commit is contained in:
JustSong 2023-08-30 21:15:56 +08:00 committed by ckt1031
parent fe291359a2
commit 03727a92c8

View File

@ -86,7 +86,7 @@ func AddChannel(c *gin.Context) {
} }
channel.CreatedTime = common.GetTimestamp() channel.CreatedTime = common.GetTimestamp()
keys := strings.Split(channel.Key, "\n") keys := strings.Split(channel.Key, "\n")
channels := make([]model.Channel, 0) channels := make([]model.Channel, 0, len(keys))
for _, key := range keys { for _, key := range keys {
if key == "" { if key == "" {
continue continue