Skip to content

Commit 9b7d9d7

Browse files
committed
Rename index to iFirstMatchedChannel
1 parent 5bfd349 commit 9b7d9d7

File tree

1 file changed

+5
-8
lines changed

1 file changed

+5
-8
lines changed

examples/chef/common/clusters/channel/ChannelManager.cpp

+5-8
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ bool isChannelMatched(const ChannelInfoType & channel, const CharSpan & match)
152152
void ChannelManager::HandleChangeChannel(CommandResponseHelper<ChangeChannelResponseType> & helper, const CharSpan & match)
153153
{
154154
std::vector<ChannelInfoType> matchedChannels;
155-
uint16_t index = 0;
155+
uint16_t iFirstMatchedChannel = 0;
156156
for (auto const & channel : mChannels)
157157
{
158158
// verify if CharSpan matches channel name
@@ -161,12 +161,9 @@ void ChannelManager::HandleChangeChannel(CommandResponseHelper<ChangeChannelResp
161161
{
162162
matchedChannels.push_back(channel);
163163
}
164-
else if (matchedChannels.size() == 0)
164+
else if (matchedChannels.empty())
165165
{
166-
// "index" is only used when we end up with matchedChannels.size() == 1.
167-
// In that case, we want it to be the number of non-matching channels we saw before
168-
// the matching one.
169-
index++;
166+
iFirstMatchedChannel++;
170167
}
171168
}
172169

@@ -178,7 +175,7 @@ void ChannelManager::HandleChangeChannel(CommandResponseHelper<ChangeChannelResp
178175
response.status = chip::app::Clusters::Channel::StatusEnum::kMultipleMatches;
179176
helper.Success(response);
180177
}
181-
else if (matchedChannels.size() == 0)
178+
else if (matchedChannels.empty())
182179
{
183180
// Error: Found no match
184181
response.status = chip::app::Clusters::Channel::StatusEnum::kNoMatches;
@@ -189,7 +186,7 @@ void ChannelManager::HandleChangeChannel(CommandResponseHelper<ChangeChannelResp
189186
response.status = chip::app::Clusters::Channel::StatusEnum::kSuccess;
190187
response.data = chip::MakeOptional(CharSpan::fromCharString("data response"));
191188
mCurrentChannel = matchedChannels[0];
192-
mCurrentChannelIndex = index;
189+
mCurrentChannelIndex = iFirstMatchedChannel;
193190
helper.Success(response);
194191
}
195192
}

0 commit comments

Comments
 (0)