mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-26 06:11:37 +00:00
e1d8b92ec6
Entries in kSTSPreloadList currently look like: class nsSTSPreload { public: const char *mHost; const bool mIncludeSubdomains; }; This is inefficient for a couple of reasons: * The structure has a bunch of wasted space: it takes 8 bytes on 32-bit platforms and 16 bytes on 64-bit platforms, even though it only uses 5 and 9 bytes, respectively. * The |const char*| requires additional space in the form of relocations (at least on Linux/Android), which doubles the space cost of individual entries. (The space cost of the relocations is mitigated somewhat on Linux and Android because of elfhack, but there's still extra cost in the on-disk format and during the load of libxul to process those relocations.) * The relocations the structure requires means that the data in it can't be shared between processes, which is important for e10s with multiple content processes. We can make it more efficient by structuring it like so: static const char kSTSPreloadHosts[] = { // One giant character array containing the hosts, in order: // "example.com\0example.org\0example.test\0..." // Use an array rather than a literal string due to compiler limitations. }; struct nsSTSPreload { // An index into kSTSPreloadHosts for the hostname. uint32_t mHostIndex: 31; // We use the same datatype for both members so that MSVC will pack // the bitfields into a single uint32_t. uint32_t mIncludeSubdomains: 1; }; nsSTSPreload now has no wasted space and is significantly smaller, especially on 64-bit platforms (saves ~29K on 32-bit platforms and ~85K on 64-bit platforms). This organization does add a couple extra operations to searching for preload list entries, depending on your platform, but the space savings make it worth it. |
||
---|---|---|
.. | ||
locales | ||
pki | ||
ssl | ||
tools | ||
.eslintrc.json | ||
android_stub.h | ||
moz.build |