github.com/zerosnake0/jzon@v0.0.9-0.20230801092939-1b135cb83f7f/type_queue.go (about) 1 package jzon 2 3 import "reflect" 4 5 type typeQueue []reflect.Type 6 7 func (tq *typeQueue) push(t reflect.Type) { 8 *tq = append(*tq, t) 9 } 10 11 // func (tq *typeQueue) pushAlsoPtr(t reflect.Type) { 12 // if t.Kind() == reflect.Ptr { 13 // *tq = append(*tq, t) 14 // } else { 15 // *tq = append(*tq, reflect.PtrTo(t), t) 16 // } 17 // } 18 19 func (tq *typeQueue) pop() (t reflect.Type) { 20 q := *tq 21 l := len(q) 22 if l == 0 { 23 return nil 24 } 25 t = q[l-1] 26 *tq = q[:l-1] 27 return 28 }