mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 17:47:44 +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
|
@ -127,7 +127,7 @@ PDFErrorOr<Vector<ByteBuffer>> PS1FontProgram::parse_subroutines(Reader& reader)
|
|||
return error("Array index out of bounds");
|
||||
|
||||
if (isdigit(entry[0])) {
|
||||
auto maybe_encrypted_size = entry.to_int();
|
||||
auto maybe_encrypted_size = entry.to_number<int>();
|
||||
if (!maybe_encrypted_size.has_value())
|
||||
return error("Malformed array");
|
||||
auto rd = TRY(parse_word(reader));
|
||||
|
@ -191,7 +191,7 @@ PDFErrorOr<float> PS1FontProgram::parse_float(Reader& reader)
|
|||
|
||||
PDFErrorOr<int> PS1FontProgram::parse_int(Reader& reader)
|
||||
{
|
||||
auto maybe_int = TRY(parse_word(reader)).to_int();
|
||||
auto maybe_int = TRY(parse_word(reader)).to_number<int>();
|
||||
if (!maybe_int.has_value())
|
||||
return error("Invalid int");
|
||||
return maybe_int.value();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue