fast-path.not.go 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. // +build notfastpath
  2. package codec
  3. import "reflect"
  4. const fastpathEnabled = false
  5. // The generated fast-path code is very large, and adds a few seconds to the build time.
  6. // This causes test execution, execution of small tools which use codec, etc
  7. // to take a long time.
  8. //
  9. // To mitigate, we now support the notfastpath tag.
  10. // This tag disables fastpath during build, allowing for faster build, test execution,
  11. // short-program runs, etc.
  12. func fastpathDecodeTypeSwitch(iv interface{}, d *Decoder) bool { return false }
  13. func fastpathEncodeTypeSwitch(iv interface{}, e *Encoder) bool { return false }
  14. func fastpathEncodeTypeSwitchSlice(iv interface{}, e *Encoder) bool { return false }
  15. func fastpathEncodeTypeSwitchMap(iv interface{}, e *Encoder) bool { return false }
  16. func fastpathDecodeSetZeroTypeSwitch(iv interface{}) bool { return false }
  17. type fastpathT struct{}
  18. type fastpathE struct {
  19. rtid uintptr
  20. rt reflect.Type
  21. encfn func(*Encoder, *codecFnInfo, reflect.Value)
  22. decfn func(*Decoder, *codecFnInfo, reflect.Value)
  23. }
  24. type fastpathA [0]fastpathE
  25. func (x fastpathA) index(rtid uintptr) int { return -1 }
  26. func (_ fastpathT) DecSliceUint8V(v []uint8, canChange bool, d *Decoder) (_ []uint8, changed bool) {
  27. fn := d.cf.get(uint8SliceTyp, true, true)
  28. d.kSlice(&fn.i, reflect.ValueOf(&v).Elem())
  29. return v, true
  30. }
  31. var fastpathAV fastpathA
  32. var fastpathTV fastpathT
  33. // ----
  34. type TestMammoth2Wrapper struct{} // to allow testMammoth work in notfastpath mode