Don't mix up capacity and length
- `make([]a, b)` create a slice of `b` elements `a` - `make([]a, b, c)` create a slice of `0` elements `a`, but reserve space for `c` of them When using `append` on the former, it will result on a slice with `b` leading elements, which is unlikely to be what we want. This commit replaces the two instances where this happens with the latter construct.
This commit is contained in:
parent
645a817685
commit
1f5c8ce353
2 changed files with 2 additions and 2 deletions
|
@ -984,7 +984,7 @@ func (h *handler) streamItemContentsHandler(w http.ResponseWriter, r *http.Reque
|
||||||
}
|
}
|
||||||
contentItems := make([]contentItem, len(entries))
|
contentItems := make([]contentItem, len(entries))
|
||||||
for i, entry := range entries {
|
for i, entry := range entries {
|
||||||
enclosures := make([]contentItemEnclosure, len(entry.Enclosures))
|
enclosures := make([]contentItemEnclosure, 0, len(entry.Enclosures))
|
||||||
for _, enclosure := range entry.Enclosures {
|
for _, enclosure := range entry.Enclosures {
|
||||||
enclosures = append(enclosures, contentItemEnclosure{URL: enclosure.URL, Type: enclosure.MimeType})
|
enclosures = append(enclosures, contentItemEnclosure{URL: enclosure.URL, Type: enclosure.MimeType})
|
||||||
}
|
}
|
||||||
|
|
|
@ -132,7 +132,7 @@ func (s *Storage) updateEnclosures(tx *sql.Tx, entry *model.Entry) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
sqlValues := make([]string, len(entry.Enclosures))
|
sqlValues := make([]string, 0, len(entry.Enclosures))
|
||||||
for _, enclosure := range entry.Enclosures {
|
for _, enclosure := range entry.Enclosures {
|
||||||
sqlValues = append(sqlValues, strings.TrimSpace(enclosure.URL))
|
sqlValues = append(sqlValues, strings.TrimSpace(enclosure.URL))
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue