另客网go项目公用的代码库

fast-path.not.go 1.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  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. func (_ fastpathT) DecSliceUint8V(v []uint8, canChange bool, d *Decoder) (_ []uint8, changed bool) {
  29. fn := d.h.fn(uint8SliceTyp, true, true)
  30. d.kSlice(&fn.i, reflect.ValueOf(&v).Elem())
  31. return v, true
  32. }
  33. var fastpathAV fastpathA
  34. var fastpathTV fastpathT
  35. // ----
  36. type TestMammoth2Wrapper struct{} // to allow testMammoth work in notfastpath mode