Skip to content

Commit e93dcb3

Browse files
committed
Use pointers in slices
1 parent 5200979 commit e93dcb3

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

parse.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ func parseInnerList(input []byte, pos int) (*InnerList, int, error) {
152152
}
153153
pos++
154154
var (
155-
items []Item
155+
items []*Item
156156
it *Item
157157
err error
158158
)
@@ -169,7 +169,7 @@ func parseInnerList(input []byte, pos int) (*InnerList, int, error) {
169169
if err != nil {
170170
return nil, pos, err
171171
}
172-
items = append(items, *it)
172+
items = append(items, it)
173173
}
174174
p, pos, err := parseParams(input, pos)
175175
if err != nil {

type.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ func (l List) Encode() string {
3030
}
3131

3232
// Dict is an ordered map of key-value pairs.
33-
type Dict []Pair
33+
type Dict []*Pair
3434

3535
// Encode serializes the dictionary.
3636
func (d Dict) Encode() string {
@@ -52,7 +52,7 @@ func (d Dict) Add(k string, v Member) Dict {
5252
return d
5353
}
5454
}
55-
d = append(d, Pair{k, v})
55+
d = append(d, &Pair{k, v})
5656
return d
5757
}
5858

@@ -92,7 +92,7 @@ type Member interface {
9292
// InnerList is an array of zero or more items having zero or more associated
9393
// parameters.
9494
type InnerList struct {
95-
Items []Item
95+
Items []*Item
9696
Params ParamList
9797
}
9898

@@ -120,7 +120,7 @@ func (i *Item) Encode() string {
120120
}
121121

122122
// ParamList is an array of zero or more parameters.
123-
type ParamList []Param
123+
type ParamList []*Param
124124

125125
// Add adds a new parameter to the list and returns the modified list.
126126
func (l ParamList) Add(k string, v BareItem) ParamList {
@@ -130,7 +130,7 @@ func (l ParamList) Add(k string, v BareItem) ParamList {
130130
return l
131131
}
132132
}
133-
l = append(l, Param{k, v})
133+
l = append(l, &Param{k, v})
134134
return l
135135
}
136136

0 commit comments

Comments
 (0)