Skip to content

Commit c2e2a4a

Browse files
authored
chore: use strings.builder instead of byte buffer pool (#81)
Signed-off-by: Timon Wong <[email protected]>
1 parent 4bbdfe3 commit c2e2a4a

File tree

3 files changed

+3
-31
lines changed

3 files changed

+3
-31
lines changed

internal/bytebufferpool/pool.go

Lines changed: 0 additions & 22 deletions
This file was deleted.

internal/checkers/common.go

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,10 @@ import (
66
"go/printer"
77
"go/token"
88
"go/types"
9+
"strings"
910
"unicode/utf8"
1011

1112
"golang.org/x/tools/go/analysis"
12-
13-
"github.com/timonwong/loggercheck/internal/bytebufferpool"
1413
)
1514

1615
const (
@@ -31,9 +30,7 @@ func extractValueFromStringArg(pass *analysis.Pass, arg ast.Expr) (value string,
3130
func renderNodeEllipsis(fset *token.FileSet, v interface{}) string {
3231
const maxLen = 20
3332

34-
buf := bytebufferpool.Get()
35-
defer bytebufferpool.Put(buf)
36-
33+
buf := &strings.Builder{}
3734
_ = printer.Fprint(buf, fset, v)
3835
s := buf.String()
3936
if utf8.RuneCountInString(s) > maxLen {

internal/rules/rules.go

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@ import (
77
"go/types"
88
"io"
99
"strings"
10-
11-
"github.com/timonwong/loggercheck/internal/bytebufferpool"
1210
)
1311

1412
var ErrInvalidRule = errors.New("invalid rule format")
@@ -44,8 +42,7 @@ func (rs *Ruleset) Match(fn *types.Func) bool {
4442
}
4543

4644
func receiverTypeOf(recvType types.Type) string {
47-
buf := bytebufferpool.Get()
48-
defer bytebufferpool.Put(buf)
45+
buf := &strings.Builder{}
4946

5047
var recvNamed *types.Named
5148
switch recvType := recvType.(type) {

0 commit comments

Comments
 (0)