refactor: use east const convention (#5409)

This change refactors the codebase to use the "east const convention", and adds a clang-format rule to follow this convention.
This commit is contained in:
Vito Tumas
2025-05-08 13:00:42 +02:00
committed by GitHub
parent 2db2791805
commit 3e152fec74
212 changed files with 812 additions and 795 deletions

View File

@@ -153,7 +153,7 @@ STObject::operator=(STObject&& other)
}
void
STObject::set(const SOTemplate& type)
STObject::set(SOTemplate const& type)
{
v_.clear();
v_.reserve(type.size());
@@ -169,7 +169,7 @@ STObject::set(const SOTemplate& type)
}
void
STObject::applyTemplate(const SOTemplate& type)
STObject::applyTemplate(SOTemplate const& type)
{
auto throwFieldErr = [](std::string const& field, char const* description) {
std::stringstream ss;
@@ -296,9 +296,9 @@ STObject::set(SerialIter& sit, int depth)
}
bool
STObject::hasMatchingEntry(const STBase& t)
STObject::hasMatchingEntry(STBase const& t)
{
const STBase* o = peekAtPField(t.getFName());
STBase const* o = peekAtPField(t.getFName());
if (!o)
return false;
@@ -357,9 +357,9 @@ STObject::getText() const
}
bool
STObject::isEquivalent(const STBase& t) const
STObject::isEquivalent(STBase const& t) const
{
const STObject* v = dynamic_cast<const STObject*>(&t);
STObject const* v = dynamic_cast<STObject const*>(&t);
if (!v)
return false;
@@ -425,7 +425,7 @@ STObject::getFieldIndex(SField const& field) const
return -1;
}
const STBase&
STBase const&
STObject::peekAtField(SField const& field) const
{
int index = getFieldIndex(field);
@@ -453,7 +453,7 @@ STObject::getFieldSType(int index) const
return v_[index]->getFName();
}
const STBase*
STBase const*
STObject::peekAtPField(SField const& field) const
{
int index = getFieldIndex(field);
@@ -536,7 +536,7 @@ STObject::isFlag(std::uint32_t f) const
std::uint32_t
STObject::getFlags(void) const
{
const STUInt32* t = dynamic_cast<const STUInt32*>(peekAtPField(sfFlags));
STUInt32 const* t = dynamic_cast<STUInt32 const*>(peekAtPField(sfFlags));
if (!t)
return 0;
@@ -574,7 +574,7 @@ STObject::makeFieldAbsent(SField const& field)
if (index == -1)
throwFieldNotFound(field);
const STBase& f = peekAtIndex(index);
STBase const& f = peekAtIndex(index);
if (f.getSType() == STI_NOTPRESENT)
return;
@@ -675,14 +675,14 @@ STObject::getFieldPathSet(SField const& field) const
return getFieldByConstRef<STPathSet>(field, empty);
}
const STVector256&
STVector256 const&
STObject::getFieldV256(SField const& field) const
{
static STVector256 const empty{};
return getFieldByConstRef<STVector256>(field, empty);
}
const STArray&
STArray const&
STObject::getFieldArray(SField const& field) const
{
static STArray const empty{};
@@ -835,7 +835,7 @@ STObject::getJson(JsonOptions options) const
}
bool
STObject::operator==(const STObject& obj) const
STObject::operator==(STObject const& obj) const
{
// This is not particularly efficient, and only compares data elements
// with binary representations