fast-path.not.go 1.4 KB

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