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:
Andreas Kling 2020-06-12 21:07:52 +02:00
parent 15f4043a7a
commit fdfda6dec2
Notes: sideshowbarker 2024-07-19 05:41:49 +09:00
55 changed files with 354 additions and 455 deletions

View file

@ -463,10 +463,9 @@ int Shell::builtin_disown(int argc, const char** argv)
Vector<size_t> job_ids;
for (auto& job_id : str_job_ids) {
bool ok;
auto id = StringView { job_id }.to_uint(ok);
if (ok)
job_ids.append(id);
auto id = StringView(job_id).to_uint();
if (id.has_value())
job_ids.append(id.value());
else
printf("Invalid job id: %s\n", job_id);
}