fast-path.not.go 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. // Copyright (c) 2012-2020 Ugorji Nwoke. All rights reserved.
  2. // Use of this source code is governed by a MIT license found in the LICENSE file.
  3. //go:build notfastpath || codec.notfastpath
  4. // +build notfastpath codec.notfastpath
  5. package codec
  6. import "reflect"
  7. const fastpathEnabled = false
  8. // The generated fast-path code is very large, and adds a few seconds to the build time.
  9. // This causes test execution, execution of small tools which use codec, etc
  10. // to take a long time.
  11. //
  12. // To mitigate, we now support the notfastpath tag.
  13. // This tag disables fastpath during build, allowing for faster build, test execution,
  14. // short-program runs, etc.
  15. func fastpathDecodeTypeSwitch(iv interface{}, d *Decoder) bool { return false }
  16. func fastpathEncodeTypeSwitch(iv interface{}, e *Encoder) bool { return false }
  17. // func fastpathEncodeTypeSwitchSlice(iv interface{}, e *Encoder) bool { return false }
  18. // func fastpathEncodeTypeSwitchMap(iv interface{}, e *Encoder) bool { return false }
  19. func fastpathDecodeSetZeroTypeSwitch(iv interface{}) bool { return false }
  20. type fastpathT struct{}
  21. type fastpathE struct {
  22. rtid uintptr
  23. rt reflect.Type
  24. encfn func(*Encoder, *codecFnInfo, reflect.Value)
  25. decfn func(*Decoder, *codecFnInfo, reflect.Value)
  26. }
  27. type fastpathA [0]fastpathE
  28. func fastpathAvIndex(rtid uintptr) int { return -1 }
  29. var fastpathAv fastpathA
  30. var fastpathTV fastpathT