Skip to content

Commit

Permalink
EnergyPreference: Simplify logic around interaction with delegate (#3…
Browse files Browse the repository at this point in the history
…2271)

`Optional<CharSpan>` is directly constructible from `Optional<MutableCharSpan>`
  • Loading branch information
robszewczyk authored Feb 22, 2024
1 parent 3edfb9c commit f2bdd1f
Showing 1 changed file with 2 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -78,9 +78,7 @@ CHIP_ERROR EnergyPrefAttrAccess::Read(const ConcreteReadAttributePath & aPath, A
Optional<MutableCharSpan> label{ MutableCharSpan(buffer) };
if ((err = gsDelegate->GetEnergyBalanceAtIndex(endpoint, index, step, label)) == CHIP_NO_ERROR)
{
BalanceStruct::Type balance = { step,
label.HasValue() ? Optional<CharSpan>(label.Value())
: Optional<CharSpan>() };
BalanceStruct::Type balance = { step, Optional<CharSpan>(label) };
ReturnErrorOnFailure(encoder.Encode(balance));
index++;
}
Expand Down Expand Up @@ -137,9 +135,7 @@ CHIP_ERROR EnergyPrefAttrAccess::Read(const ConcreteReadAttributePath & aPath, A
Optional<MutableCharSpan> label{ MutableCharSpan(buffer) };
if ((err = gsDelegate->GetLowPowerModeSensitivityAtIndex(endpoint, index, step, label)) == CHIP_NO_ERROR)
{
BalanceStruct::Type balance = { step,
label.HasValue() ? Optional<CharSpan>(label.Value())
: Optional<CharSpan>() };
BalanceStruct::Type balance = { step, Optional<CharSpan>(label) };
ReturnErrorOnFailure(encoder.Encode(balance));
index++;
}
Expand Down

0 comments on commit f2bdd1f

Please sign in to comment.