From 8d006c8615c55a943695b84f19de380361903046 Mon Sep 17 00:00:00 2001 From: jvoisin Date: Mon, 17 Feb 2025 01:26:15 +0100 Subject: [PATCH] perf(sanitizer): remove two useless calls to strings.ReplaceAll The [strings.Fields](https://pkg.go.dev/strings#Fields) considers `'\t', '\n', '\v', '\f', '\r', ' ', U+0085 (NEL), U+00A0 (NBSP).` as spaces, so no need to remove them beforehand. This is a continuation of f2f60a8f73ec2f1c82a9834452a29930f3302dbb --- internal/reader/sanitizer/truncate.go | 2 -- 1 file changed, 2 deletions(-) diff --git a/internal/reader/sanitizer/truncate.go b/internal/reader/sanitizer/truncate.go index c6afdd75..a2616ae8 100644 --- a/internal/reader/sanitizer/truncate.go +++ b/internal/reader/sanitizer/truncate.go @@ -7,8 +7,6 @@ import "strings" func TruncateHTML(input string, max int) string { text := StripTags(input) - text = strings.ReplaceAll(text, "\n", " ") - text = strings.ReplaceAll(text, "\t", " ") // Collapse multiple spaces into a single space text = strings.Join(strings.Fields(text), " ")