Skip to content

Commit

Permalink
cap arraycontainer max growth at 8192
Browse files Browse the repository at this point in the history
  • Loading branch information
jnewhouse committed Oct 21, 2020
1 parent 8277a2a commit e8fc4e5
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion arraycontainer.go
Original file line number Diff line number Diff line change
Expand Up @@ -362,7 +362,14 @@ func (ac *arrayContainer) iorArray(value2 *arrayContainer) container {
if maxPossibleCardinality > cap(value1.content) {
// doubling the capacity reduces new slice allocations in the case of
// repeated calls to iorArray().
newcontent := make([]uint16, 0, 2*maxPossibleCardinality)
newSize := 2 * maxPossibleCardinality
// the second check is to handle overly large array containers
// and should not occur in normal usage,
// as all array containers should be at most arrayDefaultMaxSize
if newSize > 8192 && maxPossibleCardinality <= 8192 {
newSize = 8192
}
newcontent := make([]uint16, 0, newSize)
copy(newcontent[len2:maxPossibleCardinality], ac.content[0:len1])
ac.content = newcontent
} else {
Expand Down

0 comments on commit e8fc4e5

Please sign in to comment.