From 8d0fd80a8076fece8a4cfe43b46bd92c5ab46119 Mon Sep 17 00:00:00 2001 From: joeybloggs Date: Fri, 5 Aug 2016 23:02:12 -0400 Subject: [PATCH] removed creation of a couple stack variables and creation of errors --- struct_level.go | 12 ++++++------ validator_instance.go | 1 - 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/struct_level.go b/struct_level.go index 921a544..e721841 100644 --- a/struct_level.go +++ b/struct_level.go @@ -105,8 +105,8 @@ func (v *validate) ReportError(field interface{}, fieldName, structFieldName, ta structFieldName = fieldName } - ns := append(v.slNs, fieldName...) - nsStruct := append(v.slStructNs, structFieldName...) + v.slNs = append(v.slNs, fieldName...) + v.slStructNs = append(v.slStructNs, structFieldName...) switch kind { case reflect.Invalid: @@ -115,8 +115,8 @@ func (v *validate) ReportError(field interface{}, fieldName, structFieldName, ta &fieldError{ tag: tag, actualTag: tag, - ns: string(ns), - structNs: string(nsStruct), + ns: string(v.slNs), + structNs: string(v.slStructNs), field: fieldName, structField: structFieldName, // param: "", @@ -130,8 +130,8 @@ func (v *validate) ReportError(field interface{}, fieldName, structFieldName, ta &fieldError{ tag: tag, actualTag: tag, - ns: string(ns), - structNs: string(nsStruct), + ns: string(v.slNs), + structNs: string(v.slStructNs), field: fieldName, structField: structFieldName, value: fv.Interface(), diff --git a/validator_instance.go b/validator_instance.go index 1e6b53d..f09ebaa 100644 --- a/validator_instance.go +++ b/validator_instance.go @@ -90,7 +90,6 @@ func New() *Validate { New: func() interface{} { return &validate{ v: v, - errs: make(ValidationErrors, 0, 4), ns: make([]byte, 0, 64), actualNs: make([]byte, 0, 64), misc: make([]byte, 32),