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:
@@ -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")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user