Added a line-break after each "if" to get more accurate coverage report

This commit is contained in:
Benoit Blanchon
2020-02-16 15:05:23 +01:00
parent 8f8c82d400
commit 0814fc185f
38 changed files with 429 additions and 214 deletions

View File

@@ -11,7 +11,8 @@ namespace ARDUINOJSON_NAMESPACE {
inline VariantSlot* CollectionData::addSlot(MemoryPool* pool) {
VariantSlot* slot = pool->allocVariant();
if (!slot) return 0;
if (!slot)
return 0;
if (_tail) {
_tail->setNextNotNull(slot);
@@ -32,7 +33,8 @@ inline VariantData* CollectionData::add(MemoryPool* pool) {
template <typename TAdaptedString>
inline VariantData* CollectionData::add(TAdaptedString key, MemoryPool* pool) {
VariantSlot* slot = addSlot(pool);
if (!slotSetKey(slot, key, pool)) return 0;
if (!slotSetKey(slot, key, pool))
return 0;
return slot->data();
}
@@ -59,8 +61,10 @@ inline bool CollectionData::copyFrom(const CollectionData& src,
} else {
var = add(pool);
}
if (!var) return false;
if (!var->copyFrom(*s->data(), pool)) return false;
if (!var)
return false;
if (!var->copyFrom(*s->data(), pool))
return false;
}
return true;
}
@@ -70,7 +74,8 @@ inline bool CollectionData::equalsObject(const CollectionData& other) const {
for (VariantSlot* slot = _head; slot; slot = slot->next()) {
VariantData* v1 = slot->data();
VariantData* v2 = other.get(adaptString(slot->key()));
if (!variantEquals(v1, v2)) return false;
if (!variantEquals(v1, v2))
return false;
count++;
}
return count == other.size();
@@ -80,9 +85,12 @@ inline bool CollectionData::equalsArray(const CollectionData& other) const {
VariantSlot* s1 = _head;
VariantSlot* s2 = other._head;
for (;;) {
if (s1 == s2) return true;
if (!s1 || !s2) return false;
if (!variantEquals(s1->data(), s2->data())) return false;
if (s1 == s2)
return true;
if (!s1 || !s2)
return false;
if (!variantEquals(s1->data(), s2->data()))
return false;
s1 = s1->next();
s2 = s2->next();
}
@@ -92,7 +100,8 @@ template <typename TAdaptedString>
inline VariantSlot* CollectionData::getSlot(TAdaptedString key) const {
VariantSlot* slot = _head;
while (slot) {
if (key.equals(slot->key())) break;
if (key.equals(slot->key()))
break;
slot = slot->next();
}
return slot;
@@ -106,7 +115,8 @@ inline VariantSlot* CollectionData::getPreviousSlot(VariantSlot* target) const {
VariantSlot* current = _head;
while (current) {
VariantSlot* next = current->next();
if (next == target) return current;
if (next == target)
return current;
current = next;
}
return 0;
@@ -124,14 +134,16 @@ inline VariantData* CollectionData::get(size_t index) const {
}
inline void CollectionData::remove(VariantSlot* slot) {
if (!slot) return;
if (!slot)
return;
VariantSlot* prev = getPreviousSlot(slot);
VariantSlot* next = slot->next();
if (prev)
prev->setNext(next);
else
_head = next;
if (!next) _tail = prev;
if (!next)
_tail = prev;
}
inline void CollectionData::remove(size_t index) {
@@ -142,7 +154,8 @@ inline size_t CollectionData::memoryUsage() const {
size_t total = 0;
for (VariantSlot* s = _head; s; s = s->next()) {
total += sizeof(VariantSlot) + s->data()->memoryUsage();
if (s->ownsKey()) total += strlen(s->key()) + 1;
if (s->ownsKey())
total += strlen(s->key()) + 1;
}
return total;
}
@@ -151,7 +164,8 @@ inline size_t CollectionData::nesting() const {
size_t maxChildNesting = 0;
for (VariantSlot* s = _head; s; s = s->next()) {
size_t childNesting = s->data()->nesting();
if (childNesting > maxChildNesting) maxChildNesting = childNesting;
if (childNesting > maxChildNesting)
maxChildNesting = childNesting;
}
return maxChildNesting + 1;
}
@@ -162,7 +176,8 @@ inline size_t CollectionData::size() const {
template <typename T>
inline void movePointer(T*& p, ptrdiff_t offset) {
if (!p) return;
if (!p)
return;
p = reinterpret_cast<T*>(
reinterpret_cast<void*>(reinterpret_cast<char*>(p) + offset));
ARDUINOJSON_ASSERT(isAligned(p));