refactor(slice): simplify SliceValidationError Error method (#3910)

* Simplify SliceValidationError Error method

* Replace fmt.Fprintf with b.WriteString

---------

Co-authored-by: huangzw <huangzw@hsmap.com>
Co-authored-by: 1911860538 <alxps1911@163.com>
This commit is contained in:
Name
2024-05-13 13:32:46 +08:00
committed by GitHub
parent a569ed8f26
commit 3f5b0afa2a
2 changed files with 21 additions and 22 deletions
+8 -4
View File
@@ -12,11 +12,15 @@ import (
func BenchmarkSliceValidationError(b *testing.B) {
const size int = 100
e := make(SliceValidationError, size)
for j := 0; j < size; j++ {
e[j] = errors.New(strconv.Itoa(j))
}
b.ReportAllocs()
b.ResetTimer()
for i := 0; i < b.N; i++ {
e := make(SliceValidationError, size)
for j := 0; j < size; j++ {
e[j] = errors.New(strconv.Itoa(j))
}
if len(e.Error()) == 0 {
b.Errorf("error")
}