From bfa6b9dcef7592e6dd8225aaa0d0ab5aef5b3f84 Mon Sep 17 00:00:00 2001 From: Dave Henderson Date: Sun, 9 Mar 2025 20:14:46 -0400 Subject: chore(refactoring): Refactor/modernizations (#2345) chore(refactoring): Refactor with modernization refactorings * range over int * replace interface{} with any * replace common map operations with maps.Copy/maps.Clone * simplifying loops with slices.Contains/ContainsFunc * modernize benchmarks with b.Loop * modernize tests with t.Context * use fmt.Appendf * range over strings.SplitSeq * use new stdlib crypto/pbkdf2 package --------- Signed-off-by: Dave Henderson --- strings/strings.go | 2 +- strings/strings_test.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'strings') diff --git a/strings/strings.go b/strings/strings.go index 007714e2..cf80f39c 100644 --- a/strings/strings.go +++ b/strings/strings.go @@ -33,7 +33,7 @@ func Indent(width int, indent, s string) (string, error) { res := make([]byte, 0, len(s)+len(indent)*lines) bol := true - for i := 0; i < len(s); i++ { + for i := range len(s) { c := s[i] if bol && c != '\n' { res = append(res, indent...) diff --git a/strings/strings_test.go b/strings/strings_test.go index 0fec6925..9c3afa8d 100644 --- a/strings/strings_test.go +++ b/strings/strings_test.go @@ -42,7 +42,7 @@ func BenchmarkIndent(b *testing.B) { longString := strings.Repeat("a fairly long string \n", 20) outs := make([]string, b.N*8) b.ResetTimer() - for i := 0; i < b.N; i++ { + for i := range b.N { outs[0+i*8], _ = Indent(20, " ", longString) outs[1+i*8], _ = Indent(-1, " ", actual) outs[2+i*8], _ = Indent(1, " ", actual) -- cgit v1.2.3