Skip to content

Commit

Permalink
Remove deprecated pdata slice resize API (#3675)
Browse files Browse the repository at this point in the history
Signed-off-by: Anthony J Mirabella <a9@aneurysm9.com>
  • Loading branch information
Aneurysm9 committed Jul 20, 2021
1 parent 809cae9 commit 78a6bec
Show file tree
Hide file tree
Showing 6 changed files with 4 additions and 704 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

## Unreleased

## 🛑 Breaking changes 🛑

- Remove Resize() from pdata slice APIs (#3675)

## v0.30.0 Beta

## 🛑 Breaking changes 🛑
Expand Down
64 changes: 0 additions & 64 deletions cmd/pdatagen/internal/base_slices.go
Original file line number Diff line number Diff line change
Expand Up @@ -195,38 +195,6 @@ func (es ${structName}) EnsureCapacity(newCap int) {
*es.orig = newOrig
}
// Resize is an operation that resizes the slice:
// 1. If the newLen <= len then equivalent with slice[0:newLen:cap].
// 2. If the newLen > len then (newLen - cap) empty elements will be appended to the slice.
//
// Here is how a new ${structName} can be initialized:
// es := New${structName}()
// es.Resize(4)
// for i := 0; i < es.Len(); i++ {
// e := es.At(i)
// // Here should set all the values for e.
// }
//
// Deprecated: Use EnsureCapacity() and AppendEmpty() instead.
func (es ${structName}) Resize(newLen int) {
oldLen := len(*es.orig)
oldCap := cap(*es.orig)
if newLen <= oldLen {
*es.orig = (*es.orig)[:newLen:oldCap]
return
}
if newLen > oldCap {
newOrig := make([]*${originName}, oldLen, newLen)
copy(newOrig, *es.orig)
*es.orig = newOrig
}
// Add extra empty elements to the array.
extraOrigs := make([]${originName}, newLen-oldLen)
for i := range extraOrigs {
*es.orig = append(*es.orig, &extraOrigs[i])
}
}
// AppendEmpty will append to the end of the slice an empty ${elementName}.
// It returns the newly added ${elementName}.
func (es ${structName}) AppendEmpty() ${elementName} {
Expand Down Expand Up @@ -380,38 +348,6 @@ func (es ${structName}) EnsureCapacity(newCap int) {
*es.orig = newOrig
}
// Resize is an operation that resizes the slice:
// 1. If the newLen <= len then equivalent with slice[0:newLen:cap].
// 2. If the newLen > len then (newLen - cap) empty elements will be appended to the slice.
//
// Here is how a new ${structName} can be initialized:
// es := New${structName}()
// es.Resize(4)
// for i := 0; i < es.Len(); i++ {
// e := es.At(i)
// // Here should set all the values for e.
// }
//
// Deprecated: Use EnsureCapacity() and AppendEmpty() instead.
func (es ${structName}) Resize(newLen int) {
oldLen := len(*es.orig)
oldCap := cap(*es.orig)
if newLen <= oldLen {
*es.orig = (*es.orig)[:newLen:oldCap]
return
}
if newLen > oldCap {
newOrig := make([]${originName}, oldLen, newLen)
copy(newOrig, *es.orig)
*es.orig = newOrig
}
// Add extra empty elements to the array.
empty := ${originName}{}
for i := oldLen; i < newLen; i++ {
*es.orig = append(*es.orig, empty)
}
}
// AppendEmpty will append to the end of the slice an empty ${elementName}.
// It returns the newly added ${elementName}.
func (es ${structName}) AppendEmpty() ${elementName} {
Expand Down
32 changes: 0 additions & 32 deletions model/pdata/generated_common.go

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

96 changes: 0 additions & 96 deletions model/pdata/generated_log.go

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

0 comments on commit 78a6bec

Please sign in to comment.