mirror of
https://github.com/RGBCube/serenity
synced 2025-05-28 05:25:09 +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
55 changed files with 354 additions and 455 deletions
|
@ -1431,14 +1431,17 @@ Vector<size_t, 2> Editor::vt_dsr()
|
|||
|
||||
if (buf[0] == '\033' && buf[1] == '[') {
|
||||
auto parts = StringView(buf + 2, length - 3).split_view(';');
|
||||
bool ok;
|
||||
row = parts[0].to_int(ok);
|
||||
if (!ok) {
|
||||
auto row_opt = parts[0].to_int();
|
||||
if (!row_opt.has_value()) {
|
||||
dbg() << "Terminal DSR issue; received garbage row";
|
||||
} else {
|
||||
row = row_opt.value();
|
||||
}
|
||||
col = parts[1].to_int(ok);
|
||||
if (!ok) {
|
||||
auto col_opt = parts[1].to_int();
|
||||
if (!col_opt.has_value()) {
|
||||
dbg() << "Terminal DSR issue; received garbage col";
|
||||
} else {
|
||||
col = col_opt.value();
|
||||
}
|
||||
}
|
||||
return { row, col };
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue