mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 03:57:44 +00:00
Replace various copies of parse_uint(String) with String::to_uint().
This commit is contained in:
parent
cea631d90c
commit
b5b44a29bb
4 changed files with 6 additions and 70 deletions
|
@ -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();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue