1
0
mirror of https://github.com/rclone/rclone.git synced 2026-01-06 10:33:34 +00:00

refactor: use strings.Builder to improve performance

This commit is contained in:
reddaisyy
2025-10-23 23:40:30 +08:00
committed by GitHub
parent 71631621c4
commit 1d0e1ea0b5
4 changed files with 21 additions and 18 deletions

View File

@@ -3,6 +3,7 @@ package lsf
import (
"bytes"
"context"
"strings"
"testing"
_ "github.com/rclone/rclone/backend/local"
@@ -140,12 +141,12 @@ file3
require.NoError(t, err)
items, _ := list.DirSorted(context.Background(), f, true, "")
var expectedOutput string
var expectedOutput strings.Builder
for _, item := range items {
expectedOutput += item.ModTime(context.Background()).Format("2006-01-02 15:04:05") + "\n"
expectedOutput.WriteString(item.ModTime(context.Background()).Format("2006-01-02 15:04:05") + "\n")
}
assert.Equal(t, expectedOutput, buf.String())
assert.Equal(t, expectedOutput.String(), buf.String())
buf = new(bytes.Buffer)
format = "sp"