Skip to content

Commit 536b316

Browse files
committed
Update batteryMonitor.cpp
1 parent 7403a5e commit 536b316

File tree

1 file changed

+2
-9
lines changed

1 file changed

+2
-9
lines changed

src/common/batteryMonitor.cpp

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -122,12 +122,7 @@ class BatteryServiceProvider : public BatteryService
122122
public:
123123
virtual int getLastBatteryLevel() override
124124
{
125-
if (currentStatus.stateOfCharge.has_value())
126-
{
127-
return (int)currentStatus.stateOfCharge.value();
128-
}
129-
else
130-
return UNKNOWN_BATTERY_LEVEL;
125+
return (int)currentStatus.stateOfCharge.value_or(UNKNOWN_BATTERY_LEVEL);
131126
}
132127

133128
virtual bool hasBattery() override
@@ -138,9 +133,7 @@ class BatteryServiceProvider : public BatteryService
138133
virtual bool isBatteryPresent() override
139134
{
140135
return (batteryMonitorhardware != nullptr) &&
141-
(currentStatus.isBatteryPresent.has_value()
142-
? currentStatus.isBatteryPresent.value()
143-
: false);
136+
currentStatus.isBatteryPresent.value_or(false);
144137
}
145138

146139
virtual void getStatus(BatteryStatus &status) override

0 commit comments

Comments
 (0)