Minor optimization of STObject::add

This commit is contained in:
Scott Schurr
2018-07-09 11:57:45 -07:00
committed by Nik Bougalis
parent 70d9d88cda
commit 574ea2c14d
2 changed files with 41 additions and 38 deletions

View File

@@ -354,12 +354,12 @@ public:
virtual void add (Serializer & s) const override
{
add (s, true); // just inner elements
add (s, withAllFields); // just inner elements
}
void addWithoutSigningFields (Serializer & s) const
{
add (s, false);
add (s, omitSigningFields);
}
// VFALCO NOTE does this return an expensive copy of an object with a
@@ -368,7 +368,7 @@ public:
Serializer getSerializer () const
{
Serializer s;
add (s, true);
add (s, withAllFields);
return s;
}
@@ -538,13 +538,22 @@ public:
}
private:
void add (Serializer & s, bool withSigningFields) const;
enum WhichFields : bool
{
// These values are carefully chosen to do the right thing if passed
// to SField::shouldInclude (bool)
omitSigningFields = false,
withAllFields = true
};
void add (Serializer & s, WhichFields whichFields) const;
// Sort the entries in an STObject into the order that they will be
// serialized. Note: they are not sorted into pointer value order, they
// are sorted by SField::fieldCode.
static std::vector<STBase const*>
getSortedFields (STObject const& objToSort);
getSortedFields (
STObject const& objToSort, WhichFields whichFields);
// Two different ways to compare STObjects.
//