From b5b44a29bbfbf83e348ab0007d04039fb252bbe5 Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Wed, 8 May 2019 19:21:51 +0200 Subject: Replace various copies of parse_uint(String) with String::to_uint(). --- Applications/Terminal/Terminal.cpp | 19 ++----------------- 1 file changed, 2 insertions(+), 17 deletions(-) (limited to 'Applications') diff --git a/Applications/Terminal/Terminal.cpp b/Applications/Terminal/Terminal.cpp index 3e628deb8d..8c68c4e241 100644 --- a/Applications/Terminal/Terminal.cpp +++ b/Applications/Terminal/Terminal.cpp @@ -116,21 +116,6 @@ inline bool is_valid_final_character(byte ch) return ch >= 0x40 && ch <= 0x7e; } -unsigned parse_uint(const String& str, bool& ok) -{ - unsigned value = 0; - for (int i = 0; i < str.length(); ++i) { - if (str[i] < '0' || str[i] > '9') { - ok = false; - return 0; - } - value = value * 10; - value += str[i] - '0'; - } - ok = true; - return value; -} - static inline Color lookup_color(unsigned color) { return Color::from_rgb(xterm_colors[color]); @@ -397,7 +382,7 @@ void Terminal::execute_xterm_command() { m_final = '@'; bool ok; - unsigned value = parse_uint(String::copy(m_xterm_param1), ok); + unsigned value = String::copy(m_xterm_param1).to_uint(ok); if (ok) { switch (value) { case 0: @@ -421,7 +406,7 @@ void Terminal::execute_escape_sequence(byte final) ParamVector params; for (auto& parampart : paramparts) { bool ok; - unsigned value = parse_uint(parampart, ok); + unsigned value = parampart.to_uint(ok); if (!ok) { m_parameters.clear_with_capacity(); m_intermediates.clear_with_capacity(); -- cgit v1.2.3