sensorlog: Remove generated IsZero logic.
The purpose of the IsZero logic was as a speed-up; the normal vom
zero-field encoding is slow, since it actually encodes fields and
then backtracks to throw away zero-valued fields. However the
generated IsZero was actually significantly *slower*, for the
native types case, and possibly also the non-native types case.
In the future we will re-enable the IsZero logic for simple
cases (no native types, no typeobject or union). And we may
enable IsZero for the more complicated cases, if we can come up
with a simple strategy that is actually faster that the default
backtracking implementation.
MultiPart: 6/6
Change-Id: Ic505113ba121db876a60318ab3270e8058a047f6
diff --git a/go/src/v.io/x/sensorlog/internal/sbmodel/types.vdl.go b/go/src/v.io/x/sensorlog/internal/sbmodel/types.vdl.go
index 6abdceb..ed58db1 100644
--- a/go/src/v.io/x/sensorlog/internal/sbmodel/types.vdl.go
+++ b/go/src/v.io/x/sensorlog/internal/sbmodel/types.vdl.go
@@ -46,34 +46,28 @@
return err
}
- var2 := (m.Desc == "")
- if !var2 {
- keyTarget3, fieldTarget4, err := fieldsTarget1.StartField("Desc")
- if err != vdl.ErrFieldNoExist && err != nil {
+ keyTarget2, fieldTarget3, err := fieldsTarget1.StartField("Desc")
+ if err != vdl.ErrFieldNoExist && err != nil {
+ return err
+ }
+ if err != vdl.ErrFieldNoExist {
+ if err := fieldTarget3.FromString(string(m.Desc), vdl.StringType); err != nil {
return err
}
- if err != vdl.ErrFieldNoExist {
- if err := fieldTarget4.FromString(string(m.Desc), vdl.StringType); err != nil {
- return err
- }
- if err := fieldsTarget1.FinishField(keyTarget3, fieldTarget4); err != nil {
- return err
- }
+ if err := fieldsTarget1.FinishField(keyTarget2, fieldTarget3); err != nil {
+ return err
}
}
- var5 := (m.SgPublishSb == "")
- if !var5 {
- keyTarget6, fieldTarget7, err := fieldsTarget1.StartField("SgPublishSb")
- if err != vdl.ErrFieldNoExist && err != nil {
+ keyTarget4, fieldTarget5, err := fieldsTarget1.StartField("SgPublishSb")
+ if err != vdl.ErrFieldNoExist && err != nil {
+ return err
+ }
+ if err != vdl.ErrFieldNoExist {
+ if err := fieldTarget5.FromString(string(m.SgPublishSb), vdl.StringType); err != nil {
return err
}
- if err != vdl.ErrFieldNoExist {
- if err := fieldTarget7.FromString(string(m.SgPublishSb), vdl.StringType); err != nil {
- return err
- }
- if err := fieldsTarget1.FinishField(keyTarget6, fieldTarget7); err != nil {
- return err
- }
+ if err := fieldsTarget1.FinishField(keyTarget4, fieldTarget5); err != nil {
+ return err
}
}
if err := t.FinishFields(fieldsTarget1); err != nil {
@@ -86,12 +80,6 @@
return nil
}
-func (m *VDeviceCfg) IsZero() bool {
-
- var1 := (*m == VDeviceCfg{})
- return var1
-}
-
type KDeviceCfg struct {
DevId string
}
@@ -111,19 +99,16 @@
return err
}
- var2 := (m.DevId == "")
- if !var2 {
- keyTarget3, fieldTarget4, err := fieldsTarget1.StartField("DevId")
- if err != vdl.ErrFieldNoExist && err != nil {
+ keyTarget2, fieldTarget3, err := fieldsTarget1.StartField("DevId")
+ if err != vdl.ErrFieldNoExist && err != nil {
+ return err
+ }
+ if err != vdl.ErrFieldNoExist {
+ if err := fieldTarget3.FromString(string(m.DevId), vdl.StringType); err != nil {
return err
}
- if err != vdl.ErrFieldNoExist {
- if err := fieldTarget4.FromString(string(m.DevId), vdl.StringType); err != nil {
- return err
- }
- if err := fieldsTarget1.FinishField(keyTarget3, fieldTarget4); err != nil {
- return err
- }
+ if err := fieldsTarget1.FinishField(keyTarget2, fieldTarget3); err != nil {
+ return err
}
}
if err := t.FinishFields(fieldsTarget1); err != nil {
@@ -136,12 +121,6 @@
return nil
}
-func (m *KDeviceCfg) IsZero() bool {
-
- var1 := (*m == KDeviceCfg{})
- return var1
-}
-
// streamdef : <DevId>/<StreamId>
// Configures a stream of data to be measured.
type VStreamDef struct {
@@ -166,50 +145,41 @@
return err
}
- var2 := (m.Desc == "")
- if !var2 {
- keyTarget3, fieldTarget4, err := fieldsTarget1.StartField("Desc")
- if err != vdl.ErrFieldNoExist && err != nil {
+ keyTarget2, fieldTarget3, err := fieldsTarget1.StartField("Desc")
+ if err != vdl.ErrFieldNoExist && err != nil {
+ return err
+ }
+ if err != vdl.ErrFieldNoExist {
+ if err := fieldTarget3.FromString(string(m.Desc), vdl.StringType); err != nil {
return err
}
- if err != vdl.ErrFieldNoExist {
- if err := fieldTarget4.FromString(string(m.Desc), vdl.StringType); err != nil {
- return err
- }
- if err := fieldsTarget1.FinishField(keyTarget3, fieldTarget4); err != nil {
- return err
- }
+ if err := fieldsTarget1.FinishField(keyTarget2, fieldTarget3); err != nil {
+ return err
}
}
- var5 := m.Sampler.IsZero()
- if !var5 {
- keyTarget6, fieldTarget7, err := fieldsTarget1.StartField("Sampler")
- if err != vdl.ErrFieldNoExist && err != nil {
- return err
- }
- if err != vdl.ErrFieldNoExist {
+ keyTarget4, fieldTarget5, err := fieldsTarget1.StartField("Sampler")
+ if err != vdl.ErrFieldNoExist && err != nil {
+ return err
+ }
+ if err != vdl.ErrFieldNoExist {
- if err := m.Sampler.FillVDLTarget(fieldTarget7, __VDLType_types_v_io_x_sensorlog_internal_sbmodel_SamplerDef); err != nil {
- return err
- }
- if err := fieldsTarget1.FinishField(keyTarget6, fieldTarget7); err != nil {
- return err
- }
- }
- }
- var8 := (m.Enabled == false)
- if !var8 {
- keyTarget9, fieldTarget10, err := fieldsTarget1.StartField("Enabled")
- if err != vdl.ErrFieldNoExist && err != nil {
+ if err := m.Sampler.FillVDLTarget(fieldTarget5, __VDLType_types_v_io_x_sensorlog_internal_sbmodel_SamplerDef); err != nil {
return err
}
- if err != vdl.ErrFieldNoExist {
- if err := fieldTarget10.FromBool(bool(m.Enabled), vdl.BoolType); err != nil {
- return err
- }
- if err := fieldsTarget1.FinishField(keyTarget9, fieldTarget10); err != nil {
- return err
- }
+ if err := fieldsTarget1.FinishField(keyTarget4, fieldTarget5); err != nil {
+ return err
+ }
+ }
+ keyTarget6, fieldTarget7, err := fieldsTarget1.StartField("Enabled")
+ if err != vdl.ErrFieldNoExist && err != nil {
+ return err
+ }
+ if err != vdl.ErrFieldNoExist {
+ if err := fieldTarget7.FromBool(bool(m.Enabled), vdl.BoolType); err != nil {
+ return err
+ }
+ if err := fieldsTarget1.FinishField(keyTarget6, fieldTarget7); err != nil {
+ return err
}
}
if err := t.FinishFields(fieldsTarget1); err != nil {
@@ -222,12 +192,6 @@
return nil
}
-func (m *VStreamDef) IsZero() bool {
-
- var1 := (*m == VStreamDef{})
- return var1
-}
-
type KStreamDef struct {
DevId string
StreamId string
@@ -248,34 +212,28 @@
return err
}
- var2 := (m.DevId == "")
- if !var2 {
- keyTarget3, fieldTarget4, err := fieldsTarget1.StartField("DevId")
- if err != vdl.ErrFieldNoExist && err != nil {
+ keyTarget2, fieldTarget3, err := fieldsTarget1.StartField("DevId")
+ if err != vdl.ErrFieldNoExist && err != nil {
+ return err
+ }
+ if err != vdl.ErrFieldNoExist {
+ if err := fieldTarget3.FromString(string(m.DevId), vdl.StringType); err != nil {
return err
}
- if err != vdl.ErrFieldNoExist {
- if err := fieldTarget4.FromString(string(m.DevId), vdl.StringType); err != nil {
- return err
- }
- if err := fieldsTarget1.FinishField(keyTarget3, fieldTarget4); err != nil {
- return err
- }
+ if err := fieldsTarget1.FinishField(keyTarget2, fieldTarget3); err != nil {
+ return err
}
}
- var5 := (m.StreamId == "")
- if !var5 {
- keyTarget6, fieldTarget7, err := fieldsTarget1.StartField("StreamId")
- if err != vdl.ErrFieldNoExist && err != nil {
+ keyTarget4, fieldTarget5, err := fieldsTarget1.StartField("StreamId")
+ if err != vdl.ErrFieldNoExist && err != nil {
+ return err
+ }
+ if err != vdl.ErrFieldNoExist {
+ if err := fieldTarget5.FromString(string(m.StreamId), vdl.StringType); err != nil {
return err
}
- if err != vdl.ErrFieldNoExist {
- if err := fieldTarget7.FromString(string(m.StreamId), vdl.StringType); err != nil {
- return err
- }
- if err := fieldsTarget1.FinishField(keyTarget6, fieldTarget7); err != nil {
- return err
- }
+ if err := fieldsTarget1.FinishField(keyTarget4, fieldTarget5); err != nil {
+ return err
}
}
if err := t.FinishFields(fieldsTarget1); err != nil {
@@ -288,12 +246,6 @@
return nil
}
-func (m *KStreamDef) IsZero() bool {
-
- var1 := (*m == KStreamDef{})
- return var1
-}
-
// Sampling script and polling frequency.
type SamplerDef struct {
// Shell script executed after every Interval, starting from Start.
@@ -317,61 +269,52 @@
return err
}
- var2 := (m.Script == "")
- if !var2 {
- keyTarget3, fieldTarget4, err := fieldsTarget1.StartField("Script")
- if err != vdl.ErrFieldNoExist && err != nil {
+ keyTarget2, fieldTarget3, err := fieldsTarget1.StartField("Script")
+ if err != vdl.ErrFieldNoExist && err != nil {
+ return err
+ }
+ if err != vdl.ErrFieldNoExist {
+ if err := fieldTarget3.FromString(string(m.Script), vdl.StringType); err != nil {
return err
}
- if err != vdl.ErrFieldNoExist {
- if err := fieldTarget4.FromString(string(m.Script), vdl.StringType); err != nil {
- return err
- }
- if err := fieldsTarget1.FinishField(keyTarget3, fieldTarget4); err != nil {
- return err
- }
+ if err := fieldsTarget1.FinishField(keyTarget2, fieldTarget3); err != nil {
+ return err
}
}
- var wireValue5 time_2.Time
- if err := time_2.TimeFromNative(&wireValue5, m.Start); err != nil {
+ var wireValue4 time_2.Time
+ if err := time_2.TimeFromNative(&wireValue4, m.Start); err != nil {
return err
}
- var6 := wireValue5.IsZero()
- if !var6 {
- keyTarget7, fieldTarget8, err := fieldsTarget1.StartField("Start")
- if err != vdl.ErrFieldNoExist && err != nil {
+ keyTarget5, fieldTarget6, err := fieldsTarget1.StartField("Start")
+ if err != vdl.ErrFieldNoExist && err != nil {
+ return err
+ }
+ if err != vdl.ErrFieldNoExist {
+
+ if err := wireValue4.FillVDLTarget(fieldTarget6, __VDLType_types_time_Time); err != nil {
return err
}
- if err != vdl.ErrFieldNoExist {
-
- if err := wireValue5.FillVDLTarget(fieldTarget8, __VDLType_types_time_Time); err != nil {
- return err
- }
- if err := fieldsTarget1.FinishField(keyTarget7, fieldTarget8); err != nil {
- return err
- }
+ if err := fieldsTarget1.FinishField(keyTarget5, fieldTarget6); err != nil {
+ return err
}
}
- var wireValue9 time_2.Duration
- if err := time_2.DurationFromNative(&wireValue9, m.Interval); err != nil {
+ var wireValue7 time_2.Duration
+ if err := time_2.DurationFromNative(&wireValue7, m.Interval); err != nil {
return err
}
- var10 := wireValue9.IsZero()
- if !var10 {
- keyTarget11, fieldTarget12, err := fieldsTarget1.StartField("Interval")
- if err != vdl.ErrFieldNoExist && err != nil {
+ keyTarget8, fieldTarget9, err := fieldsTarget1.StartField("Interval")
+ if err != vdl.ErrFieldNoExist && err != nil {
+ return err
+ }
+ if err != vdl.ErrFieldNoExist {
+
+ if err := wireValue7.FillVDLTarget(fieldTarget9, __VDLType_types_time_Duration); err != nil {
return err
}
- if err != vdl.ErrFieldNoExist {
-
- if err := wireValue9.FillVDLTarget(fieldTarget12, __VDLType_types_time_Duration); err != nil {
- return err
- }
- if err := fieldsTarget1.FinishField(keyTarget11, fieldTarget12); err != nil {
- return err
- }
+ if err := fieldsTarget1.FinishField(keyTarget8, fieldTarget9); err != nil {
+ return err
}
}
if err := t.FinishFields(fieldsTarget1); err != nil {
@@ -384,12 +327,6 @@
return nil
}
-func (m *SamplerDef) IsZero() bool {
-
- var1 := (*m == SamplerDef{})
- return var1
-}
-
// sdata : <DevId>/<StreamId>/<Timestamp>
// Measured data value or error.
type KDataPoint struct {
@@ -411,55 +348,46 @@
return err
}
- var2 := (m.DevId == "")
- if !var2 {
- keyTarget3, fieldTarget4, err := fieldsTarget1.StartField("DevId")
- if err != vdl.ErrFieldNoExist && err != nil {
+ keyTarget2, fieldTarget3, err := fieldsTarget1.StartField("DevId")
+ if err != vdl.ErrFieldNoExist && err != nil {
+ return err
+ }
+ if err != vdl.ErrFieldNoExist {
+ if err := fieldTarget3.FromString(string(m.DevId), vdl.StringType); err != nil {
return err
}
- if err != vdl.ErrFieldNoExist {
- if err := fieldTarget4.FromString(string(m.DevId), vdl.StringType); err != nil {
- return err
- }
- if err := fieldsTarget1.FinishField(keyTarget3, fieldTarget4); err != nil {
- return err
- }
- }
- }
- var5 := (m.StreamId == "")
- if !var5 {
- keyTarget6, fieldTarget7, err := fieldsTarget1.StartField("StreamId")
- if err != vdl.ErrFieldNoExist && err != nil {
+ if err := fieldsTarget1.FinishField(keyTarget2, fieldTarget3); err != nil {
return err
}
- if err != vdl.ErrFieldNoExist {
- if err := fieldTarget7.FromString(string(m.StreamId), vdl.StringType); err != nil {
- return err
- }
- if err := fieldsTarget1.FinishField(keyTarget6, fieldTarget7); err != nil {
- return err
- }
+ }
+ keyTarget4, fieldTarget5, err := fieldsTarget1.StartField("StreamId")
+ if err != vdl.ErrFieldNoExist && err != nil {
+ return err
+ }
+ if err != vdl.ErrFieldNoExist {
+ if err := fieldTarget5.FromString(string(m.StreamId), vdl.StringType); err != nil {
+ return err
+ }
+ if err := fieldsTarget1.FinishField(keyTarget4, fieldTarget5); err != nil {
+ return err
}
}
- var wireValue8 time_2.Time
- if err := time_2.TimeFromNative(&wireValue8, m.Timestamp); err != nil {
+ var wireValue6 time_2.Time
+ if err := time_2.TimeFromNative(&wireValue6, m.Timestamp); err != nil {
return err
}
- var9 := wireValue8.IsZero()
- if !var9 {
- keyTarget10, fieldTarget11, err := fieldsTarget1.StartField("Timestamp")
- if err != vdl.ErrFieldNoExist && err != nil {
+ keyTarget7, fieldTarget8, err := fieldsTarget1.StartField("Timestamp")
+ if err != vdl.ErrFieldNoExist && err != nil {
+ return err
+ }
+ if err != vdl.ErrFieldNoExist {
+
+ if err := wireValue6.FillVDLTarget(fieldTarget8, __VDLType_types_time_Time); err != nil {
return err
}
- if err != vdl.ErrFieldNoExist {
-
- if err := wireValue8.FillVDLTarget(fieldTarget11, __VDLType_types_time_Time); err != nil {
- return err
- }
- if err := fieldsTarget1.FinishField(keyTarget10, fieldTarget11); err != nil {
- return err
- }
+ if err := fieldsTarget1.FinishField(keyTarget7, fieldTarget8); err != nil {
+ return err
}
}
if err := t.FinishFields(fieldsTarget1); err != nil {
@@ -472,12 +400,6 @@
return nil
}
-func (m *KDataPoint) IsZero() bool {
-
- var1 := (*m == KDataPoint{})
- return var1
-}
-
type (
// VDataPoint represents any single field of the VDataPoint union type.
VDataPoint interface {
@@ -490,7 +412,6 @@
// __VDLReflect describes the VDataPoint union type.
__VDLReflect(__VDataPointReflect)
FillVDLTarget(vdl.Target, *vdl.Type) error
- IsZero() bool
}
// VDataPointValue represents field Value of the VDataPoint union type.
VDataPointValue struct{ Value float64 }
@@ -539,12 +460,6 @@
return nil
}
-func (m VDataPointValue) IsZero() bool {
-
- var2 := (m.Value == float64(0))
- return var2
-}
-
func (x VDataPointError) Index() int { return 1 }
func (x VDataPointError) Interface() interface{} { return x.Value }
func (x VDataPointError) Name() string { return "Error" }
@@ -577,12 +492,6 @@
return nil
}
-func (m VDataPointError) IsZero() bool {
-
- unionField2 := false
- return unionField2
-}
-
func init() {
vdl.Register((*VDeviceCfg)(nil))
vdl.Register((*KDeviceCfg)(nil))