Bug 189272 - [WTF] Add support for compactly storing multiple optional members in a class
Summary: [WTF] Add support for compactly storing multiple optional members in a class
Status: NEW
Alias: None
Product: WebKit
Classification: Unclassified
Component: Web Template Framework (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Nobody
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2018-09-04 13:54 PDT by Sam Weinig
Modified: 2018-09-04 13:54 PDT (History)
0 users

See Also:


Attachments
Proof of concept (9.08 KB, text/x-csrc)
2018-09-04 13:54 PDT, Sam Weinig
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Sam Weinig 2018-09-04 13:54:03 PDT
Created attachment 348845 [details]
Proof of concept

When you have a class that has multiple std::optional members (and you aren't using CompactOptional from https://bugs.webkit.org/show_bug.cgi?id=189231) you end up wasting a lot of space due to the bool each std::optional must contain. I think we can do better.

An initial idea, attached as a proof of concept, is to store the bools all together as a bitset and have each optional member be able to access that bitset via some OBJECT_OFFSETOF fun. This requires a bit of macro nastiness and bit more typing per optional value, so I am not 100% sure it's worth it.