mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 04:27:44 +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
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;
|
Core::ElapsedTimer clock;
|
||||||
clock.start();
|
clock.start();
|
||||||
auto update_timer = Core::Timer::construct(100, [&] {
|
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");
|
auto& stop_button = widget->add<GUI::Button>("Stop");
|
||||||
|
|
|
@ -1570,7 +1570,7 @@ void Device::draw_statistics_overlay(Gfx::Bitmap& target)
|
||||||
static int frame_counter;
|
static int frame_counter;
|
||||||
|
|
||||||
frame_counter++;
|
frame_counter++;
|
||||||
int milliseconds = 0;
|
i64 milliseconds = 0;
|
||||||
if (timer.is_valid())
|
if (timer.is_valid())
|
||||||
milliseconds = timer.elapsed();
|
milliseconds = timer.elapsed();
|
||||||
else
|
else
|
||||||
|
|
|
@ -17,7 +17,7 @@ class Performance final : public DOM::EventTarget {
|
||||||
public:
|
public:
|
||||||
virtual ~Performance() override;
|
virtual ~Performance() override;
|
||||||
|
|
||||||
double now() const { return m_timer.elapsed(); }
|
double now() const { return static_cast<double>(m_timer.elapsed()); }
|
||||||
double time_origin() const;
|
double time_origin() const;
|
||||||
|
|
||||||
JS::GCPtr<NavigationTiming::PerformanceTiming> timing();
|
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)
|
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);
|
float progress = min((float)elapsed_ms / (float)m_duration, 1.0f);
|
||||||
|
|
||||||
if (on_update)
|
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
|
bool WindowManager::is_considered_doubleclick(MouseEvent const& event, DoubleClickInfo::ClickMetadata const& metadata) const
|
||||||
{
|
{
|
||||||
int elapsed_since_last_click = metadata.clock.elapsed();
|
i64 elapsed_ms_since_last_click = metadata.clock.elapsed();
|
||||||
if (elapsed_since_last_click < m_double_click_speed) {
|
if (elapsed_ms_since_last_click < m_double_click_speed) {
|
||||||
auto diff = event.position() - metadata.last_position;
|
auto diff = event.position() - metadata.last_position;
|
||||||
auto distance_travelled_squared = diff.x() * diff.x() + diff.y() * diff.y();
|
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))
|
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);
|
block_on_job(job);
|
||||||
exit_code = job.exit_code();
|
exit_code = job.exit_code();
|
||||||
}
|
}
|
||||||
iteration_times.add(timer.elapsed());
|
iteration_times.add(static_cast<float>(timer.elapsed()));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (number_of_iterations == 1) {
|
if (number_of_iterations == 1) {
|
||||||
|
|
|
@ -40,7 +40,7 @@ ErrorOr<int> serenity_main(Main::Arguments args)
|
||||||
auto loader = maybe_loader.release_value();
|
auto loader = maybe_loader.release_value();
|
||||||
|
|
||||||
Core::ElapsedTimer sample_timer { true };
|
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();
|
int remaining_samples = sample_count > 0 ? sample_count : NumericLimits<int>::max();
|
||||||
unsigned total_loaded_samples = 0;
|
unsigned total_loaded_samples = 0;
|
||||||
|
|
||||||
|
@ -48,8 +48,7 @@ ErrorOr<int> serenity_main(Main::Arguments args)
|
||||||
if (remaining_samples > 0) {
|
if (remaining_samples > 0) {
|
||||||
sample_timer = sample_timer.start_new();
|
sample_timer = sample_timer.start_new();
|
||||||
auto samples = loader->get_more_samples(min(MAX_CHUNK_SIZE, remaining_samples));
|
auto samples = loader->get_more_samples(min(MAX_CHUNK_SIZE, remaining_samples));
|
||||||
auto elapsed = static_cast<u64>(sample_timer.elapsed());
|
total_loader_time += sample_timer.elapsed();
|
||||||
total_loader_time += static_cast<u64>(elapsed);
|
|
||||||
if (!samples.is_error()) {
|
if (!samples.is_error()) {
|
||||||
remaining_samples -= samples.value().size();
|
remaining_samples -= samples.value().size();
|
||||||
total_loaded_samples += samples.value().size();
|
total_loaded_samples += samples.value().size();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue