Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove calls to InitEmpty when not necessary, remove AttributeValue.InitEmpty #2225

Merged
merged 1 commit into from
Nov 30, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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