moved instantiation a little down

This commit is contained in:
silverqx
2023-07-08 15:03:14 +02:00
parent 0dc91ceb0d
commit 414f967443
2 changed files with 16 additions and 16 deletions
+9 -9
View File
@@ -2133,10 +2133,6 @@ namespace Orm::Tiny::Concerns
return attributes;
}
C serializableAttributes;
if constexpr (HasReserveMethod<C>)
serializableAttributes.reserve(attributes.size());
// Get visible attributes only
/* Compute visible keys on attributes map/vector, the intersection is needed
to compute only keys that really exists. */
@@ -2144,6 +2140,10 @@ namespace Orm::Tiny::Concerns
ranges::set_intersection(AttributeUtils::keys(attributes), visible,
ranges::inserter(visibleKeys, visibleKeys.cend()));
C serializableAttributes;
if constexpr (HasReserveMethod<C>)
serializableAttributes.reserve(attributes.size());
for (const auto &[key, value] : attributes)
if (visibleKeys.contains(key)) {
if constexpr (std::is_same_v<C, QVariantMap>)
@@ -2170,8 +2170,6 @@ namespace Orm::Tiny::Concerns
if (hidden.empty())
return std::move(attributes);
QVariantMap serializableAttributes;
/* Remove hidden attributes, from the map container returned by
the getSerializableVisibleAttributes()! */
/* Compute hidden keys on attributes map, the intersection is needed to compute
@@ -2180,6 +2178,8 @@ namespace Orm::Tiny::Concerns
ranges::set_intersection(AttributeUtils::keys(attributes), hidden,
ranges::inserter(hiddenKeys, hiddenKeys.cend()));
QVariantMap serializableAttributes;
for (auto it = attributes.constBegin();
it != attributes.constEnd(); ++it
)
@@ -2200,9 +2200,6 @@ namespace Orm::Tiny::Concerns
if (hidden.empty())
return std::move(attributes);
QVector<AttributeItem> serializableAttributes;
serializableAttributes.reserve(attributes.size());
/* Remove hidden attributes, from the vector container returned by
the getSerializableVisibleAttributes()! */
/* Compute hidden keys on attributes vector, the intersection is needed
@@ -2211,6 +2208,9 @@ namespace Orm::Tiny::Concerns
ranges::set_intersection(AttributeUtils::keys(attributes), hidden,
ranges::inserter(hiddenKeys, hiddenKeys.cend()));
QVector<AttributeItem> serializableAttributes;
serializableAttributes.reserve(attributes.size());
for (auto &&[key, value] : attributes)
if (!hiddenKeys.contains(key))
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
@@ -1473,10 +1473,6 @@ namespace Concerns
if (visible.empty())
return relations;
RelationsContainerType serializableRelations;
if constexpr (HasReserveMethod<RelationsContainerType>)
serializableRelations.reserve(relations.size());
// Get visible relations only
/* Compute visible keys on relations map, the intersection is needed to compute
only keys that really exists. */
@@ -1485,6 +1481,10 @@ namespace Concerns
AttributeUtils::keys<AllRelations...>(relations), visible,
ranges::inserter(visibleKeys, visibleKeys.cend()));
RelationsContainerType serializableRelations;
if constexpr (HasReserveMethod<RelationsContainerType>)
serializableRelations.reserve(relations.size());
for (const auto &[key, value] : relations)
if (visibleKeys.contains(key))
serializableRelations.emplace(key, value);
@@ -1502,9 +1502,6 @@ namespace Concerns
if (hidden.empty())
return std::move(relations);
RelationsContainer<AllRelations...> serializableRelations;
serializableRelations.reserve(relations.size());
/* Remove hidden relations, from the map container returned by
the getSerializableVisibleRelations()! */
/* Compute hidden keys on relations map, the intersection is needed to compute
@@ -1514,6 +1511,9 @@ namespace Concerns
AttributeUtils::keys<AllRelations...>(relations), hidden,
ranges::inserter(hiddenKeys, hiddenKeys.cend()));
RelationsContainer<AllRelations...> serializableRelations;
serializableRelations.reserve(relations.size());
for (auto &&[key, value] : relations)
if (!hiddenKeys.contains(key))
serializableRelations.emplace(std::move(key), std::move(value)); // try_emplace() not needed