Selling point is that it never touches the heap. Intended use case is
cheaply returning a variable, bounded, and small number of things from
a function.
Specifically, there are situations where we'd like to return things like
ArrayView<ArrayView<float>>
where we currently have to allocate an array of ArrayView<float> for
the outer ArrayView to point to, which is a bother; however, although
the outer ArrayView is of variable size, that size is statically
guaranteed to not exceed some small constant. After this CL, we'll be
able to instead return
BoundedInlineVector<ArrayView<float>, kSmallConstant>
which is much more convenient. We already had the option of returning e.g.
std::vector<ArrayView<float>>
but that would bloat our binary with code to handle heap allocations
in places we'd rather be lean and mean.
https://godbolt.org/z/r-vcPj demonstrates that the overhead compared to
a raw C array + a size is ~zero.
Bug: webrtc:11391
Change-Id: Ifb6d937193052588be641aa62cc67ba0ec64ded6
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/168944
Commit-Queue: Karl Wiberg <kwiberg@webrtc.org>
Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org>
Reviewed-by: Per Åhgren <peah@webrtc.org>
Reviewed-by: Danil Chapovalov <danilchap@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#30663}