(value2 *arrayContainer)
| 386 | } |
| 387 | |
| 388 | func (ac *arrayContainer) iorArray(value2 *arrayContainer) container { |
| 389 | value1 := ac |
| 390 | len1 := value1.getCardinality() |
| 391 | len2 := value2.getCardinality() |
| 392 | maxPossibleCardinality := len1 + len2 |
| 393 | if maxPossibleCardinality > cap(value1.content) { |
| 394 | // doubling the capacity reduces new slice allocations in the case of |
| 395 | // repeated calls to iorArray(). |
| 396 | newSize := 2 * maxPossibleCardinality |
| 397 | // the second check is to handle overly large array containers |
| 398 | // and should not occur in normal usage, |
| 399 | // as all array containers should be at most arrayDefaultMaxSize |
| 400 | if newSize > 2*arrayDefaultMaxSize && maxPossibleCardinality <= 2*arrayDefaultMaxSize { |
| 401 | newSize = 2 * arrayDefaultMaxSize |
| 402 | } |
| 403 | newcontent := make([]uint16, 0, newSize) |
| 404 | copy(newcontent[len2:maxPossibleCardinality], ac.content[0:len1]) |
| 405 | ac.content = newcontent |
| 406 | } else { |
| 407 | copy(ac.content[len2:maxPossibleCardinality], ac.content[0:len1]) |
| 408 | } |
| 409 | nl := union2by2(value1.content[len2:maxPossibleCardinality], value2.content, ac.content) |
| 410 | ac.content = ac.content[:nl] // reslice to match actual used capacity |
| 411 | |
| 412 | if nl > arrayDefaultMaxSize { |
| 413 | // Only converting to a bitmap when arrayDefaultMaxSize |
| 414 | // is actually exceeded minimizes conversions in the case of repeated |
| 415 | // calls to iorArray(). |
| 416 | return ac.toBitmapContainer() |
| 417 | } |
| 418 | return ac |
| 419 | } |
| 420 | |
| 421 | // Note: such code does not make practical sense, except for lazy evaluations |
| 422 | func (ac *arrayContainer) iorBitmap(bc2 *bitmapContainer) container { |
no test coverage detected