1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-23 19:15:07 +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:
Andreas Kling 2020-06-12 21:07:52 +02:00
parent 15f4043a7a
commit fdfda6dec2
55 changed files with 354 additions and 455 deletions

View file

@ -177,10 +177,9 @@ RefPtr<Inode> DevPtsFSInode::lookup(StringView name)
if (name == "." || name == "..")
return fs().get_inode(identifier());
bool ok;
unsigned pty_index = name.to_uint(ok);
if (ok && ptys->contains(pty_index)) {
return fs().get_inode({ fsid(), pty_index_to_inode_index(pty_index) });
auto pty_index = name.to_uint();
if (pty_index.has_value() && ptys->contains(pty_index.value())) {
return fs().get_inode({ fsid(), pty_index_to_inode_index(pty_index.value()) });
}
return {};