Skip to content

Commit 806081a

Browse files
committed
I believe simple loop will be smaller code than std::distance
1 parent 5a200be commit 806081a

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

src/data-model-providers/codegen/CodegenDataModelProvider.cpp

+5-3
Original file line numberDiff line numberDiff line change
@@ -40,15 +40,13 @@
4040
#include <app/util/persistence/AttributePersistenceProvider.h>
4141
#include <app/util/persistence/DefaultAttributePersistenceProvider.h>
4242
#include <data-model-providers/codegen/EmberMetadata.h>
43-
#include <iterator>
4443
#include <lib/core/CHIPError.h>
4544
#include <lib/core/DataModelTypes.h>
4645
#include <lib/support/CodeUtils.h>
4746
#include <lib/support/ScopedBuffer.h>
4847
#include <lib/support/SpanSearchValue.h>
4948

5049
#include <cstdint>
51-
#include <iterator>
5250
#include <optional>
5351

5452
namespace chip {
@@ -278,7 +276,11 @@ CHIP_ERROR CodegenDataModelProvider::ServerClusters(EndpointId endpointId,
278276

279277
// assume the clusters on endpoint does not change in between these two loops
280278
auto clusters = mRegistry.ClustersOnEndpoint(endpointId);
281-
size_t registryClusterCount = std::distance(clusters.begin(), clusters.end());
279+
size_t registryClusterCount = 0;
280+
for ([[maybe_unused]] auto _ : clusters)
281+
{
282+
registryClusterCount++;
283+
}
282284

283285
ReturnErrorOnFailure(builder.EnsureAppendCapacity(registryClusterCount));
284286

0 commit comments

Comments
 (0)