perf: preallocate array capacity

This commit is contained in:
JustSong 2023-08-30 21:15:56 +08:00
parent ef2c5abb5b
commit abbf2fded0

View File

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