Skip to content

Commit

Permalink
Remove calls to InitEmpty when not necessary, remove AttributeValue.I…
Browse files Browse the repository at this point in the history
…nitEmpty (#2225)

Signed-off-by: Bogdan Drutu <[email protected]>
  • Loading branch information
bogdandrutu authored Nov 30, 2020
1 parent 60eca16 commit 7c28105
Show file tree
Hide file tree
Showing 4 changed files with 0 additions and 15 deletions.
4 changes: 0 additions & 4 deletions cmd/pdatagen/internal/base_slices.go
Original file line number Diff line number Diff line change
Expand Up @@ -381,7 +381,6 @@ const sliceValueTestTemplate = `func Test${structName}(t *testing.T) {
es.Resize(7)
emptyVal := New${elementName}()
emptyVal.InitEmpty()
testVal := generateTest${elementName}()
assert.EqualValues(t, 7, es.Len())
for i := 0; i < es.Len(); i++ {
Expand Down Expand Up @@ -434,7 +433,6 @@ func Test${structName}_CopyTo(t *testing.T) {
func Test${structName}_Resize(t *testing.T) {
es := generateTest${structName}()
emptyVal := New${elementName}()
emptyVal.InitEmpty()
// Test Resize less elements.
const resizeSmallLen = 4
expectedEs := make(map[*${originName}]bool, resizeSmallLen)
Expand Down Expand Up @@ -477,13 +475,11 @@ func Test${structName}_Resize(t *testing.T) {
func Test${structName}_Append(t *testing.T) {
es := generateTest${structName}()
emptyVal := New${elementName}()
emptyVal.InitEmpty()
es.Append(emptyVal)
assert.EqualValues(t, *(es.At(7)).orig, *emptyVal.orig)
emptyVal2 := New${elementName}()
emptyVal2.InitEmpty()
es.Append(emptyVal2)
assert.EqualValues(t, *(es.At(8)).orig, *emptyVal2.orig)
Expand Down
4 changes: 0 additions & 4 deletions consumer/pdata/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -136,10 +136,6 @@ func NewAttributeValueArray() AttributeValue {
return AttributeValue{orig: orig}
}

func (a AttributeValue) InitEmpty() {
*a.orig = otlpcommon.AnyValue{}
}

// Type returns the type of the value for this AttributeValue.
// Calling this function on zero-initialized AttributeValue will cause a panic.
func (a AttributeValue) Type() AttributeValueType {
Expand Down
4 changes: 0 additions & 4 deletions consumer/pdata/generated_common_test.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 0 additions & 3 deletions receiver/fluentforwardreceiver/conversion.go
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,6 @@ func (melr *MessageEventLogRecord) LogRecords() pdata.LogSlice {
func (melr *MessageEventLogRecord) DecodeMsg(dc *msgp.Reader) error {
melr.LogSlice = pdata.NewLogSlice()
melr.LogSlice.Resize(1)
melr.LogSlice.At(0).Body().InitEmpty()

var arrLen uint32
var err error
Expand Down Expand Up @@ -276,7 +275,6 @@ func (fe *ForwardEventLogRecords) DecodeMsg(dc *msgp.Reader) (err error) {
fe.LogSlice.Resize(int(entryLen))
for i := 0; i < int(entryLen); i++ {
lr := fe.LogSlice.At(i)
lr.Body().InitEmpty()

err = parseEntryToLogRecord(dc, lr)
if err != nil {
Expand Down Expand Up @@ -400,7 +398,6 @@ func (pfe *PackedForwardEventLogRecords) parseEntries(entriesRaw []byte, isGzipp
for {
lr := pdata.NewLogRecord()
lr.InitEmpty()
lr.Body().InitEmpty()

err := parseEntryToLogRecord(msgpReader, lr)
if err != nil {
Expand Down

0 comments on commit 7c28105

Please sign in to comment.