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