From d1dfe8db73576a3c5b2740f2ad6d5fb08de489c9 Mon Sep 17 00:00:00 2001 From: Anton Tiurin Date: Tue, 17 Feb 2015 19:03:34 +0300 Subject: [PATCH] [TextFormatter] Preallocate enough memory for keys to speedup. Benchmarks: * BenchmarkSmallTextFormatter: 6140/5943 ~3% * BenchmarkLargeTextFormatter: 28050/24789 ~11% Signed-off-by: Anton Tiurin --- text_formatter.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/text_formatter.go b/text_formatter.go index 78e7889..4e51734 100644 --- a/text_formatter.go +++ b/text_formatter.go @@ -43,7 +43,7 @@ type TextFormatter struct { func (f *TextFormatter) Format(entry *Entry) ([]byte, error) { - var keys []string + var keys []string = make([]string, 0, len(entry.Data)) for k := range entry.Data { keys = append(keys, k) }