From 48b96e4385e52bcf9dc17e694273e0e72a5eff57 Mon Sep 17 00:00:00 2001 From: "google-labs-jules[bot]" <161369871+google-labs-jules[bot]@users.noreply.github.com> Date: Fri, 13 Mar 2026 08:45:07 +0000 Subject: [PATCH] =?UTF-8?q?=E2=9A=A1=20[perf]=20optimize=20string=20concat?= =?UTF-8?q?enation=20in=20resolveDiscordRefs?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: hobbyistlabs-coder <267281733+hobbyistlabs-coder@users.noreply.github.com> --- pkg/channels/discord/discord.go | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/pkg/channels/discord/discord.go b/pkg/channels/discord/discord.go index f7e3b7bfd..661378f85 100644 --- a/pkg/channels/discord/discord.go +++ b/pkg/channels/discord/discord.go @@ -578,6 +578,11 @@ func (c *DiscordChannel) resolveDiscordRefs(s *discordgo.Session, text string, g // 2. Expand Discord message links (max 3, same guild only) matches := msgLinkRe.FindAllStringSubmatch(text, 3) + if len(matches) == 0 { + return text + } + var sb strings.Builder + sb.WriteString(text) for _, m := range matches { if len(m) < 4 { continue @@ -595,10 +600,10 @@ func (c *DiscordChannel) resolveDiscordRefs(s *discordgo.Session, text string, g if msg.Author != nil { author = msg.Author.Username } - text += fmt.Sprintf("\n[linked message from %s]: %s", author, msg.Content) + fmt.Fprintf(&sb, "\n[linked message from %s]: %s", author, msg.Content) } - return text + return sb.String() } // stripBotMention removes the bot mention from the message content.