@@ -152,7 +152,7 @@ bool isChannelMatched(const ChannelInfoType & channel, const CharSpan & match)
152
152
void ChannelManager::HandleChangeChannel (CommandResponseHelper<ChangeChannelResponseType> & helper, const CharSpan & match)
153
153
{
154
154
std::vector<ChannelInfoType> matchedChannels;
155
- uint16_t index = 0 ;
155
+ uint16_t iFirstMatchedChannel = 0 ;
156
156
for (auto const & channel : mChannels )
157
157
{
158
158
// verify if CharSpan matches channel name
@@ -161,12 +161,9 @@ void ChannelManager::HandleChangeChannel(CommandResponseHelper<ChangeChannelResp
161
161
{
162
162
matchedChannels.push_back (channel);
163
163
}
164
- else if (matchedChannels.size () == 0 )
164
+ else if (matchedChannels.empty () )
165
165
{
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++;
170
167
}
171
168
}
172
169
@@ -178,7 +175,7 @@ void ChannelManager::HandleChangeChannel(CommandResponseHelper<ChangeChannelResp
178
175
response.status = chip::app::Clusters::Channel::StatusEnum::kMultipleMatches ;
179
176
helper.Success (response);
180
177
}
181
- else if (matchedChannels.size () == 0 )
178
+ else if (matchedChannels.empty () )
182
179
{
183
180
// Error: Found no match
184
181
response.status = chip::app::Clusters::Channel::StatusEnum::kNoMatches ;
@@ -189,7 +186,7 @@ void ChannelManager::HandleChangeChannel(CommandResponseHelper<ChangeChannelResp
189
186
response.status = chip::app::Clusters::Channel::StatusEnum::kSuccess ;
190
187
response.data = chip::MakeOptional (CharSpan::fromCharString (" data response" ));
191
188
mCurrentChannel = matchedChannels[0 ];
192
- mCurrentChannelIndex = index ;
189
+ mCurrentChannelIndex = iFirstMatchedChannel ;
193
190
helper.Success (response);
194
191
}
195
192
}
0 commit comments