Skip to content
This repository has been archived by the owner on Dec 16, 2021. It is now read-only.

Commit

Permalink
Preallocate messages array on SetMessages
Browse files Browse the repository at this point in the history
  • Loading branch information
Bios-Marcel committed Nov 16, 2019
1 parent 773acd4 commit af54fbe
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions ui/chatview.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,24 +3,26 @@ package ui
import (
"bytes"
"fmt"
linkshortener "github.com/Bios-Marcel/shortnotforlong"
"math"
"regexp"
"strconv"
"strings"
"sync"

linkshortener "github.com/Bios-Marcel/shortnotforlong"
"github.com/gdamore/tcell"

"github.com/Bios-Marcel/cordless/config"
"github.com/Bios-Marcel/cordless/discordutil"
"github.com/Bios-Marcel/cordless/times"
"github.com/Bios-Marcel/cordless/ui/tviewutil"
"github.com/gdamore/tcell"

"github.com/Bios-Marcel/cordless/config"
// Blank import for initializing the tview formatter
_ "github.com/Bios-Marcel/cordless/syntax"
"github.com/Bios-Marcel/discordgo"
"github.com/Bios-Marcel/tview"

// Blank import for initializing the tview formatter
_ "github.com/Bios-Marcel/cordless/syntax"

"github.com/alecthomas/chroma"
"github.com/alecthomas/chroma/formatters"
"github.com/alecthomas/chroma/lexers"
Expand Down Expand Up @@ -877,7 +879,7 @@ func (chatView *ChatView) SignalSelectionDeleted() {
// SetMessages defines all currently displayed messages. Parsing and
// manipulation of single message elements happens in this function.
func (chatView *ChatView) SetMessages(messages []*discordgo.Message) {
chatView.data = make([]*discordgo.Message, 0)
chatView.data = make([]*discordgo.Message, 0, len(messages))
chatView.internalTextView.Clear()

chatView.AddMessages(messages)
Expand Down

0 comments on commit af54fbe

Please sign in to comment.