Skip to content

Commit

Permalink
upsome
Browse files Browse the repository at this point in the history
  • Loading branch information
inhere committed Sep 25, 2020
1 parent db9f746 commit c4e81b0
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 0 deletions.
36 changes: 36 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# CHANGE LOG

## V2

- use sync.Pool for optimize create Validation.

```go
// Validation definition
type Validation struct {
// for optimize create instance. refer go-playground/validator
v *Validation
pool *sync.Pool

// ...
}

v.pool = &sync.Pool{
New: func() interface{} {
return &Validation{
v: v,
}
},
}
```

- all data operate move to DataSource

```go
type DataFace interface {
BindStruct() error
SafeVal(field string) interface{}

...
}

```
8 changes: 8 additions & 0 deletions validate.go
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,14 @@ func newValidation(data DataFace) *Validation {
v.validatorMetas[n] = newFuncMeta(n, true, fv)
}

// v.pool = &sync.Pool{
// New: func() interface{} {
// return &Validation{
// v: v,
// }
// },
// }

return v
}

Expand Down
4 changes: 4 additions & 0 deletions validation.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@ const (

// Validation definition
type Validation struct {
// for optimize create instance. refer go-playground/validator
// v *Validation
// pool *sync.Pool

// source input data
data DataFace
// all validated fields list
Expand Down

0 comments on commit c4e81b0

Please sign in to comment.