Bug 1600963 - reduce size of principal KeyVals; r=mccr8

By declaring the individual enum types to fit in a `uint8_t`, and
rearranging the templated `KeyValT` struct, we can pack `KeyValT`
to save a word of storage.

Differential Revision: https://phabricator.services.mozilla.com/D55687

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Nathan Froyd 2019-12-03 22:20:03 +00:00
Родитель 3c6e6ca1c9
Коммит feb4f82205
4 изменённых файлов: 5 добавлений и 4 удалений

Просмотреть файл

@ -261,9 +261,10 @@ class BasePrincipal : public nsJSPrincipals {
template<typename SerializedKey>
struct KeyValT
{
static_assert(sizeof(SerializedKey) == 1, "SerializedKey should be a uint8_t");
SerializedKey key;
bool valueWasSerialized;
nsCString value;
SerializedKey key;
};
private:

Просмотреть файл

@ -59,7 +59,7 @@ class ContentPrincipal final : public BasePrincipal {
virtual nsresult PopulateJSONObject(Json::Value& aObject) override;
// Serializable keys are the valid enum fields the serialization supports
enum SerializableKeys { eURI = 0, eDomain, eSuffix, eMax = eSuffix };
enum SerializableKeys : uint8_t { eURI = 0, eDomain, eSuffix, eMax = eSuffix };
typedef mozilla::BasePrincipal::KeyValT<SerializableKeys> KeyVal;
static already_AddRefed<BasePrincipal> FromProperties(

Просмотреть файл

@ -62,7 +62,7 @@ class ExpandedPrincipal : public nsIExpandedPrincipal,
virtual nsresult PopulateJSONObject(Json::Value& aObject) override;
// Serializable keys are the valid enum fields the serialization supports
enum SerializableKeys { eSpecs = 0, eSuffix, eMax = eSuffix };
enum SerializableKeys : uint8_t { eSpecs = 0, eSuffix, eMax = eSuffix };
typedef mozilla::BasePrincipal::KeyValT<SerializableKeys> KeyVal;
static already_AddRefed<BasePrincipal> FromProperties(

Просмотреть файл

@ -86,7 +86,7 @@ class NullPrincipal final : public BasePrincipal {
virtual nsresult PopulateJSONObject(Json::Value& aObject) override;
// Serializable keys are the valid enum fields the serialization supports
enum SerializableKeys { eSpec = 0, eSuffix, eMax = eSuffix };
enum SerializableKeys : uint8_t { eSpec = 0, eSuffix, eMax = eSuffix };
typedef mozilla::BasePrincipal::KeyValT<SerializableKeys> KeyVal;
static already_AddRefed<BasePrincipal> FromProperties(