mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-07-06 09:01:53 +00:00
AK: Make string-to-number conversion helpers return Optional
Get rid of the weird old signature: - int StringType::to_int(bool& ok) const And replace it with sensible new signature: - Optional<int> StringType::to_int() const
This commit is contained in:
parent
15f4043a7a
commit
fdfda6dec2
Notes:
sideshowbarker
2024-07-19 05:41:49 +09:00
Author: https://github.com/awesomekling
Commit: fdfda6dec2
55 changed files with 354 additions and 455 deletions
|
@ -124,9 +124,10 @@ static Optional<u32> string_to_variable_value(const StringView& string_value, co
|
|||
}
|
||||
|
||||
if (variable.type_name == "int") {
|
||||
bool success = false;
|
||||
auto value = string_value.to_int(success);
|
||||
return success ? value : Optional<u32>();
|
||||
auto value = string_value.to_int();
|
||||
if (value.has_value())
|
||||
return value.value();
|
||||
return {};
|
||||
}
|
||||
|
||||
if (variable.type_name == "bool") {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue