Skip to content

Commit

Permalink
Rename index to iFirstMatchedChannel
Browse files Browse the repository at this point in the history
  • Loading branch information
erwinpan1 committed Feb 9, 2024
1 parent 5bfd349 commit 9b7d9d7
Showing 1 changed file with 5 additions and 8 deletions.
13 changes: 5 additions & 8 deletions examples/chef/common/clusters/channel/ChannelManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ bool isChannelMatched(const ChannelInfoType & channel, const CharSpan & match)
void ChannelManager::HandleChangeChannel(CommandResponseHelper<ChangeChannelResponseType> & helper, const CharSpan & match)
{
std::vector<ChannelInfoType> matchedChannels;
uint16_t index = 0;
uint16_t iFirstMatchedChannel = 0;
for (auto const & channel : mChannels)
{
// verify if CharSpan matches channel name
Expand All @@ -161,12 +161,9 @@ void ChannelManager::HandleChangeChannel(CommandResponseHelper<ChangeChannelResp
{
matchedChannels.push_back(channel);
}
else if (matchedChannels.size() == 0)
else if (matchedChannels.empty())
{
// "index" is only used when we end up with matchedChannels.size() == 1.
// In that case, we want it to be the number of non-matching channels we saw before
// the matching one.
index++;
iFirstMatchedChannel++;
}
}

Expand All @@ -178,7 +175,7 @@ void ChannelManager::HandleChangeChannel(CommandResponseHelper<ChangeChannelResp
response.status = chip::app::Clusters::Channel::StatusEnum::kMultipleMatches;
helper.Success(response);
}
else if (matchedChannels.size() == 0)
else if (matchedChannels.empty())
{
// Error: Found no match
response.status = chip::app::Clusters::Channel::StatusEnum::kNoMatches;
Expand All @@ -189,7 +186,7 @@ void ChannelManager::HandleChangeChannel(CommandResponseHelper<ChangeChannelResp
response.status = chip::app::Clusters::Channel::StatusEnum::kSuccess;
response.data = chip::MakeOptional(CharSpan::fromCharString("data response"));
mCurrentChannel = matchedChannels[0];
mCurrentChannelIndex = index;
mCurrentChannelIndex = iFirstMatchedChannel;
helper.Success(response);
}
}
Expand Down

0 comments on commit 9b7d9d7

Please sign in to comment.