diff options
author | Andreas Kling <awesomekling@gmail.com> | 2019-12-09 17:45:40 +0100 |
---|---|---|
committer | Andreas Kling <awesomekling@gmail.com> | 2019-12-09 17:51:21 +0100 |
commit | 6f4c380d95429ef4615f0a9f40d6fec9e1469764 (patch) | |
tree | 545bbb6260bcbf427e48e98fd6bbebb989bf0590 /Applications/Welcome | |
parent | 1726c17d0d4325f11124e270ae1658110af606d0 (diff) | |
download | serenity-6f4c380d95429ef4615f0a9f40d6fec9e1469764.zip |
AK: Use size_t for the length of strings
Using int was a mistake. This patch changes String, StringImpl,
StringView and StringBuilder to use size_t instead of int for lengths.
Obviously a lot of code needs to change as a result of this.
Diffstat (limited to 'Applications/Welcome')
-rw-r--r-- | Applications/Welcome/TextWidget.cpp | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/Applications/Welcome/TextWidget.cpp b/Applications/Welcome/TextWidget.cpp index 3ca2d0d07d..6da59a2163 100644 --- a/Applications/Welcome/TextWidget.cpp +++ b/Applications/Welcome/TextWidget.cpp @@ -66,20 +66,20 @@ void TextWidget::resize_event(GResizeEvent& event) void TextWidget::wrap_and_set_height() { Vector<String> words; - int start = -1; - for (int i = 0; i < m_text.length(); i++) { + Optional<size_t> start; + for (size_t i = 0; i < m_text.length(); i++) { auto ch = m_text[i]; if (ch == ' ' || ch == '\t' || ch == '\r' || ch == '\n') { - if (start != -1) - words.append(m_text.substring(start, i - start)); + if (start.has_value()) + words.append(m_text.substring(start.value(), i - start.value())); start = -1; - } else if (start == -1) { + } else if (!start.has_value()) { start = i; } } - if (start != -1) - words.append(m_text.substring(start, m_text.length() - start)); + if (start.has_value()) + words.append(m_text.substring(start, m_text.length() - start.value())); auto rect = frame_inner_rect(); if (frame_thickness() > 0) |