blob: f11b4674f817b32e5a7858dcf92f46b9acca3f95 [file] [log] [blame]
sslobodrd046be82019-01-16 10:02:22 -05001// 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
6package codec
7
8import "reflect"
9
10const 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
20func fastpathDecodeTypeSwitch(iv interface{}, d *Decoder) bool { return false }
21func fastpathEncodeTypeSwitch(iv interface{}, e *Encoder) bool { return false }
22func fastpathEncodeTypeSwitchSlice(iv interface{}, e *Encoder) bool { return false }
23func fastpathEncodeTypeSwitchMap(iv interface{}, e *Encoder) bool { return false }
24func fastpathDecodeSetZeroTypeSwitch(iv interface{}) bool { return false }
25
26type fastpathT struct{}
27type fastpathE struct {
28 rtid uintptr
29 rt reflect.Type
30 encfn func(*Encoder, *codecFnInfo, reflect.Value)
31 decfn func(*Decoder, *codecFnInfo, reflect.Value)
32}
33type fastpathA [0]fastpathE
34
35func (x fastpathA) index(rtid uintptr) int { return -1 }
36
37func (_ 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
43var fastpathAV fastpathA
44var fastpathTV fastpathT
45
46// ----
47type TestMammoth2Wrapper struct{} // to allow testMammoth work in notfastpath mode