diff options
author | Ali Mohammad Pur <ali.mpfard@gmail.com> | 2022-03-27 22:55:03 +0430 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2022-03-27 21:05:44 +0200 |
commit | b732edf61cc388c01d4d04c35999b095c042b667 (patch) | |
tree | 8981b3aadaf54a384f5876c6c0c7ce32034a4c15 /Userland/Libraries/LibLine/Editor.cpp | |
parent | f6afb70b07e0e016dd9749a7b61dde9347b795ad (diff) | |
download | serenity-b732edf61cc388c01d4d04c35999b095c042b667.zip |
LibLine: Avoid pointless size_t <-> ssize_t cast
Just a small cleanup.
Diffstat (limited to 'Userland/Libraries/LibLine/Editor.cpp')
-rw-r--r-- | Userland/Libraries/LibLine/Editor.cpp | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/Userland/Libraries/LibLine/Editor.cpp b/Userland/Libraries/LibLine/Editor.cpp index 35ac617042..c2bd3c3a5b 100644 --- a/Userland/Libraries/LibLine/Editor.cpp +++ b/Userland/Libraries/LibLine/Editor.cpp @@ -827,9 +827,9 @@ void Editor::handle_read_event() } m_incomplete_data.append(keybuf, nread); - nread = m_incomplete_data.size(); + auto available_bytes = m_incomplete_data.size(); - if (nread == 0) { + if (available_bytes == 0) { m_input_error = Error::Empty; finish(); return; @@ -839,12 +839,12 @@ void Editor::handle_read_event() // Discard starting bytes until they make sense as utf-8. size_t valid_bytes = 0; - while (nread) { - Utf8View { StringView { m_incomplete_data.data(), (size_t)nread } }.validate(valid_bytes); - if (valid_bytes) + while (available_bytes > 0) { + Utf8View { StringView { m_incomplete_data.data(), available_bytes } }.validate(valid_bytes); + if (valid_bytes != 0) break; m_incomplete_data.take_first(); - --nread; + --available_bytes; } Utf8View input_view { StringView { m_incomplete_data.data(), valid_bytes } }; |