[webkit-dev] Compile error in WebGL2RenderingContext.cpp

Maciej Stachowiak mjs at apple.com
Thu Jan 17 11:13:51 PST 2019



> On Jan 17, 2019, at 10:15 AM, Michael Catanzaro <mcatanzaro at igalia.com> wrote:
> 
> 
> 
> On Thu, Jan 17, 2019 at 11:12 AM, Darin Adler <darin at apple.com> wrote:
>> Vector’s inline capacity feature was originally created as an alternative to variable length arrays for most of the purposes people would want to put them.
> 
> Any advantages of this over std::array (which is widely-used in WebKit)?

std::array is fixed size. So you can’t do Darin’s described trick of using the stack for small enough cases but falling back to the heap for large cases, for a  buffer whose size is not known at compile time.

std::array seems fine to use for cases that are known to be fixed size at compile time. I would imagine it saves space by not having to separately track size and capacity. I don’t know if std::array holds its values inline or in an external heap buffer always. If it always uses a heap buffer, then it’s probably  worse than a normal C array for strictly local buffers. It could still be ok for fixed-size arrays stored in objects.

Regards,
Maciej


More information about the webkit-dev mailing list