github.com/trim21/go-phpserialize@v0.0.22-0.20240301204449-2fca0319b3f0/internal/encoder/compiler_norace.go (about) 1 //go:build !race 2 3 package encoder 4 5 func compileToGetCodeSet(typeID uintptr) (encoder, error) { 6 if typeID > typeAddr.MaxTypeAddr || typeID < typeAddr.BaseTypeAddr { 7 return compileToGetEncoderSlowPath(typeID) 8 } 9 10 index := (typeID - typeAddr.BaseTypeAddr) >> typeAddr.AddrShift 11 if enc := cachedEncoder[index]; enc != nil { 12 return enc, nil 13 } 14 enc, err := compileTypeID(typeID) 15 if err != nil { 16 return nil, err 17 } 18 cachedEncoder[index] = enc 19 return enc, nil 20 }