mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 14:48:14 +00:00
Everywhere: Use to_number<T> instead of to_{int,uint,float,double}
In a bunch of cases, this actually ends up simplifying the code as to_number will handle something such as: ``` Optional<I> opt; if constexpr (IsSigned<I>) opt = view.to_int<I>(); else opt = view.to_uint<I>(); ``` For us. The main goal here however is to have a single generic number conversion API between all of the String classes.
This commit is contained in:
parent
a4ecc65398
commit
e2e7c4d574
155 changed files with 397 additions and 412 deletions
|
@ -2084,7 +2084,7 @@ ErrorOr<RefPtr<AST::Node>> Parser::parse_io_redirect()
|
|||
Optional<int> io_number;
|
||||
|
||||
if (peek().type == Token::Type::IoNumber)
|
||||
io_number = consume().value.bytes_as_string_view().to_int();
|
||||
io_number = consume().value.to_number<int>();
|
||||
|
||||
if (auto io_file = TRY(parse_io_file(start_position, io_number)))
|
||||
return io_file;
|
||||
|
@ -2194,7 +2194,7 @@ ErrorOr<RefPtr<AST::Node>> Parser::parse_io_file(AST::Position start_position, O
|
|||
source_fd);
|
||||
}
|
||||
|
||||
auto maybe_target_fd = text.bytes_as_string_view().to_int();
|
||||
auto maybe_target_fd = text.to_number<int>();
|
||||
if (maybe_target_fd.has_value()) {
|
||||
auto target_fd = maybe_target_fd.release_value();
|
||||
if (is_less)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue