Skip to content

Commit ae38638

Browse files
committed
Switched to regular expressions to check if the value is in [0-100] range.
1 parent b367df9 commit ae38638

File tree

1 file changed

+1
-3
lines changed

1 file changed

+1
-3
lines changed

src/lib/zswapobject/zswapobject.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,7 @@
1616

1717
bool ZSwapObject::CheckPercent(const std::string& Value) const
1818
{
19-
if (Value.empty()) return true;
20-
const int ValueInt = std::stoi(Value);
21-
return (ValueInt < 0) || (ValueInt > 100);
19+
return !std::regex_match(Value, std::regex("^\\d{1,2}|100$"));
2220
}
2321

2422
bool ZSwapObject::CheckEnabled(const std::string& Value) const

0 commit comments

Comments
 (0)