*Better* ItemCollection.Append

This commit is contained in:
Marius Orcsik 2021-08-22 18:59:57 +02:00
parent 3d91847f7f
commit 71f08af09f
No known key found for this signature in database
GPG key ID: DBF5E47F5DBC4D21

View file

@ -43,13 +43,7 @@ func (i ItemCollection) MarshalJSON() ([]byte, error) {
// Append facilitates adding elements to Item arrays
// and ensures ItemCollection implements the Collection interface
func (i *ItemCollection) Append(o Item) error {
oldLen := len(*i)
d := make(ItemCollection, oldLen+1)
for k, it := range *i {
d[k] = it
}
d[oldLen] = o
*i = d
*i = append(*i, o)
return nil
}