Skip to content

Commit

Permalink
Use StringBuilder instead of std::stringstream
Browse files Browse the repository at this point in the history
  • Loading branch information
erwinpan1 committed Feb 13, 2024
1 parent 4af0b95 commit f32ad21
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions examples/chef/common/clusters/channel/ChannelManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -137,14 +137,13 @@ CHIP_ERROR ChannelManager::HandleGetCurrentChannel(AttributeValueEncoder & aEnco

bool ChannelManager::isChannelMatched(const ChannelInfoType & channel, const chip::CharSpan & match)
{
std::stringstream ss;
ss << channel.majorNumber << "." << channel.minorNumber;
std::string number = ss.str();
StringBuilder<16> channelNum;
channelNum.AddFormat("%d.%d", channel.majorNumber, channel.minorNumber);

auto isMatch = [&match](const Optional<chip::CharSpan> & a) { return a.HasValue() && a.Value().data_equal(match); };

return isMatch(channel.name) || isMatch(channel.affiliateCallSign) || isMatch(channel.callSign) ||
match.data_equal(chip::CharSpan::fromCharString(number.c_str()));
match.data_equal(chip::CharSpan::fromCharString(channelNum.c_str()));
}

void ChannelManager::HandleChangeChannel(CommandResponseHelper<ChangeChannelResponseType> & helper, const CharSpan & match)
Expand Down

0 comments on commit f32ad21

Please sign in to comment.