Skip to content

Commit

Permalink
EnergyPreference: Simplify logic around interaction with delegate
Browse files Browse the repository at this point in the history
`Optional<CharSpan>` is directly constructible from `Optional<MutableCharSpan>`
  • Loading branch information
robszewczyk committed Feb 22, 2024
1 parent b8de5cc commit adfbc00
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 adfbc00

Please sign in to comment.