mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 05:17:34 +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
|
@ -370,8 +370,8 @@ ErrorOr<void> MainWidget::initialize_menubar(GUI::Window& window)
|
|||
auto layer_x_position = data_and_type.metadata.get("pixelpaint-layer-x");
|
||||
auto layer_y_position = data_and_type.metadata.get("pixelpaint-layer-y");
|
||||
if (layer_x_position.has_value() && layer_y_position.has_value()) {
|
||||
auto x = layer_x_position.value().to_int();
|
||||
auto y = layer_y_position.value().to_int();
|
||||
auto x = layer_x_position.value().to_number<int>();
|
||||
auto y = layer_y_position.value().to_number<int>();
|
||||
if (x.has_value() && x.value()) {
|
||||
auto pasted_layer_location = Gfx::IntPoint { x.value(), y.value() };
|
||||
|
||||
|
@ -1211,7 +1211,7 @@ ErrorOr<void> MainWidget::initialize_menubar(GUI::Window& window)
|
|||
}
|
||||
}
|
||||
|
||||
auto zoom_level_optional = value.view().trim("%"sv, TrimMode::Right).to_int();
|
||||
auto zoom_level_optional = value.view().trim("%"sv, TrimMode::Right).to_number<int>();
|
||||
if (!zoom_level_optional.has_value()) {
|
||||
// Indicate that a parse-error occurred by resetting the text to the current state.
|
||||
editor->on_scale_change(editor->scale());
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue