Skip to content

Commit

Permalink
address comments
Browse files Browse the repository at this point in the history
  • Loading branch information
yunhanw-google committed May 20, 2022
1 parent 60f5883 commit 232201a
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 20 deletions.
2 changes: 1 addition & 1 deletion src/app/AttributePathParams.h
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ struct AttributePathParams
return true;
}

bool IsAttributePathOverlapped(const AttributePathParams & other) const
bool Intersects(const AttributePathParams & other) const
{
VerifyOrReturnError(HasWildcardEndpointId() || other.HasWildcardEndpointId() || mEndpointId == other.mEndpointId, false);
VerifyOrReturnError(HasWildcardClusterId() || other.HasWildcardClusterId() || mClusterId == other.mClusterId, false);
Expand Down
33 changes: 15 additions & 18 deletions src/app/ClusterStateCache.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -454,31 +454,28 @@ CHIP_ERROR ClusterStateCache::OnUpdateDataVersionFilterList(DataVersionFilterIBs
CHIP_ERROR err = CHIP_NO_ERROR;
TLV::TLVWriter backup;

for (auto & attribute : aAttributePaths)
{
if (attribute.HasWildcardAttributeId())
{
mRequestPathSet.insert(attribute);
}
}

for (auto & attribute1 : aAttributePaths)
{
bool intersected = false;
if (attribute1.HasWildcardAttributeId())
{
continue;
}

auto attribute2 = std::begin(mRequestPathSet);
while (attribute2 != std::end(mRequestPathSet))
{
if (attribute1.IsAttributePathOverlapped(*attribute2))
for (auto & attribute2 : aAttributePaths)
{
attribute2 = mRequestPathSet.erase(attribute2);
if (attribute2.HasWildcardAttributeId())
{
continue;
}

if (attribute1.Intersects(attribute2))
{
intersected = true;
break;
}
}
else

if (!intersected)
{
++attribute2;
mRequestPathSet.insert(attribute1);
}
}
}
Expand Down
3 changes: 2 additions & 1 deletion src/controller/tests/data_model/TestRead.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -431,7 +431,8 @@ void TestReadInteraction::TestReadSubscribeAttributeResponseWithCache(nlTestSuit
NL_TEST_ASSERT(apSuite, delegate.mNumAttributeResponse == 6);
NL_TEST_ASSERT(apSuite, !delegate.mReadError);
Optional<DataVersion> version1;
NL_TEST_ASSERT(apSuite, cache.GetVersion(Test::kMockEndpoint2, Test::MockClusterId(3), version1) == CHIP_NO_ERROR);
app::ConcreteClusterPath clusterPath1(Test::kMockEndpoint2, Test::MockClusterId(3));
NL_TEST_ASSERT(apSuite, cache.GetVersion(clusterPath1, version1) == CHIP_NO_ERROR);
NL_TEST_ASSERT(apSuite, !version1.HasValue());
delegate.mNumAttributeResponse = 0;
}
Expand Down

0 comments on commit 232201a

Please sign in to comment.