schema/pool.go
raw| 1 | package schema |
| 2 | |
| 3 | import ( |
| 4 | "reflect" |
| 5 | "sync" |
| 6 | ) |
| 7 | |
| 8 | // sync pools |
| 9 | var ( |
| 10 | normalPool sync.Map |
| 11 | poolInitializer = func(reflectType reflect.Type) FieldNewValuePool { |
| 12 | v, _ := normalPool.LoadOrStore(reflectType, &sync.Pool{ |
| 13 | New: func() interface{} { |
| 14 | return reflect.New(reflectType).Interface() |
| 15 | }, |
| 16 | }) |
| 17 | return v.(FieldNewValuePool) |
| 18 | } |
| 19 | ) |