[TextFormatter] Preallocate enough memory for keys to speedup.

Benchmarks:
 * BenchmarkSmallTextFormatter: 6140/5943 ~3%
 * BenchmarkLargeTextFormatter: 28050/24789 ~11%

Signed-off-by: Anton Tiurin <noxiouz@yandex.ru>
This commit is contained in:
Anton Tiurin 2015-02-17 19:03:34 +03:00
parent 38a6ff9215
commit d1dfe8db73
1 changed files with 1 additions and 1 deletions

View File

@ -43,7 +43,7 @@ type TextFormatter struct {
func (f *TextFormatter) Format(entry *Entry) ([]byte, error) { 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 { for k := range entry.Data {
keys = append(keys, k) keys = append(keys, k)
} }