From 0524cd023b63b3529edea960c0fcf78f13bca63f Mon Sep 17 00:00:00 2001 From: Gabriel Vasile Date: Thu, 12 Oct 2023 22:46:16 +0900 Subject: [PATCH] enable reusing records in csv/tsv detection This change should help with allocations, but ideally there would be no allocations when detecting csv. For that to happen the detection needs to move from using stdlib csv reader to something else. --- internal/magic/text_csv.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/internal/magic/text_csv.go b/internal/magic/text_csv.go index 83e395ed..84ed6492 100644 --- a/internal/magic/text_csv.go +++ b/internal/magic/text_csv.go @@ -20,7 +20,7 @@ func Tsv(raw []byte, limit uint32) bool { func sv(in []byte, comma rune, limit uint32) bool { r := csv.NewReader(dropLastLine(in, limit)) r.Comma = comma - r.TrimLeadingSpace = true + r.ReuseRecord = true r.LazyQuotes = true r.Comment = '#'