mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-21 23:20:20 +00:00
Userland: Silence warnings from ElapsedTimer::elapsed() type change
We changed elapsed() to return i64 instead of int as that's what AK::Time::to_milliseconds() returns, causing a bunch of implicit lossy conversions in callers. Clean those up with a mix of type changes and casts.
This commit is contained in:
parent
48bf0b1408
commit
a492e2018d
Notes:
sideshowbarker
2024-07-17 10:31:19 +09:00
Author: https://github.com/ADKaster Commit: https://github.com/SerenityOS/serenity/commit/a492e2018d Pull-request: https://github.com/SerenityOS/serenity/pull/16771 Reviewed-by: https://github.com/kleinesfilmroellchen Reviewed-by: https://github.com/linusg ✅
7 changed files with 9 additions and 10 deletions
|
@ -327,7 +327,7 @@ static bool prompt_to_stop_profiling(pid_t pid, DeprecatedString const& process_
|
|||
Core::ElapsedTimer clock;
|
||||
clock.start();
|
||||
auto update_timer = Core::Timer::construct(100, [&] {
|
||||
timer_label.set_text(DeprecatedString::formatted("{:.1} seconds", clock.elapsed() / 1000.0f));
|
||||
timer_label.set_text(DeprecatedString::formatted("{:.1} seconds", static_cast<float>(clock.elapsed()) / 1000.0f));
|
||||
});
|
||||
|
||||
auto& stop_button = widget->add<GUI::Button>("Stop");
|
||||
|
|
|
@ -1570,7 +1570,7 @@ void Device::draw_statistics_overlay(Gfx::Bitmap& target)
|
|||
static int frame_counter;
|
||||
|
||||
frame_counter++;
|
||||
int milliseconds = 0;
|
||||
i64 milliseconds = 0;
|
||||
if (timer.is_valid())
|
||||
milliseconds = timer.elapsed();
|
||||
else
|
||||
|
|
|
@ -17,7 +17,7 @@ class Performance final : public DOM::EventTarget {
|
|||
public:
|
||||
virtual ~Performance() override;
|
||||
|
||||
double now() const { return m_timer.elapsed(); }
|
||||
double now() const { return static_cast<double>(m_timer.elapsed()); }
|
||||
double time_origin() const;
|
||||
|
||||
JS::GCPtr<NavigationTiming::PerformanceTiming> timing();
|
||||
|
|
|
@ -47,7 +47,7 @@ void Animation::was_removed(Badge<Compositor>)
|
|||
|
||||
bool Animation::update(Badge<Compositor>, Gfx::Painter& painter, Screen& screen, Gfx::DisjointIntRectSet& flush_rects)
|
||||
{
|
||||
int elapsed_ms = m_timer.elapsed();
|
||||
i64 const elapsed_ms = m_timer.elapsed();
|
||||
float progress = min((float)elapsed_ms / (float)m_duration, 1.0f);
|
||||
|
||||
if (on_update)
|
||||
|
|
|
@ -1086,8 +1086,8 @@ auto WindowManager::DoubleClickInfo::metadata_for_button(MouseButton button) ->
|
|||
|
||||
bool WindowManager::is_considered_doubleclick(MouseEvent const& event, DoubleClickInfo::ClickMetadata const& metadata) const
|
||||
{
|
||||
int elapsed_since_last_click = metadata.clock.elapsed();
|
||||
if (elapsed_since_last_click < m_double_click_speed) {
|
||||
i64 elapsed_ms_since_last_click = metadata.clock.elapsed();
|
||||
if (elapsed_ms_since_last_click < m_double_click_speed) {
|
||||
auto diff = event.position() - metadata.last_position;
|
||||
auto distance_travelled_squared = diff.x() * diff.x() + diff.y() * diff.y();
|
||||
if (distance_travelled_squared <= (m_max_distance_for_double_click * m_max_distance_for_double_click))
|
||||
|
|
|
@ -1007,7 +1007,7 @@ int Shell::builtin_time(int argc, char const** argv)
|
|||
block_on_job(job);
|
||||
exit_code = job.exit_code();
|
||||
}
|
||||
iteration_times.add(timer.elapsed());
|
||||
iteration_times.add(static_cast<float>(timer.elapsed()));
|
||||
}
|
||||
|
||||
if (number_of_iterations == 1) {
|
||||
|
|
|
@ -40,7 +40,7 @@ ErrorOr<int> serenity_main(Main::Arguments args)
|
|||
auto loader = maybe_loader.release_value();
|
||||
|
||||
Core::ElapsedTimer sample_timer { true };
|
||||
u64 total_loader_time = 0;
|
||||
i64 total_loader_time = 0;
|
||||
int remaining_samples = sample_count > 0 ? sample_count : NumericLimits<int>::max();
|
||||
unsigned total_loaded_samples = 0;
|
||||
|
||||
|
@ -48,8 +48,7 @@ ErrorOr<int> serenity_main(Main::Arguments args)
|
|||
if (remaining_samples > 0) {
|
||||
sample_timer = sample_timer.start_new();
|
||||
auto samples = loader->get_more_samples(min(MAX_CHUNK_SIZE, remaining_samples));
|
||||
auto elapsed = static_cast<u64>(sample_timer.elapsed());
|
||||
total_loader_time += static_cast<u64>(elapsed);
|
||||
total_loader_time += sample_timer.elapsed();
|
||||
if (!samples.is_error()) {
|
||||
remaining_samples -= samples.value().size();
|
||||
total_loaded_samples += samples.value().size();
|
||||
|
|
Loading…
Reference in a new issue