Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Skip to content
Commit fa806e44 authored by Yeabkal Wubshit's avatar Yeabkal Wubshit
Browse files

Avoid Temporary Memory Allocation in LSQ2 Velocity Calculation

When calculating LSQ2 velocity with no-weights, we used to create two
vectors: one for "age" of the movements since the latest movement, and
one for the movements' position. We then passed this to a static  helper
function to calculate velocity.

This CL avoids the creation of these intermediate vectors by calculating
velocity in one pass. Furthermore, we're now clearing out old data
points (i.e. the ones that are past the horizon) in the "add" operation
for LSQ2. This means that the "getVelocity" method always gets called
with the accumulated movements guaranteed to fall within the horizon.

A minor clean up that is a side-effect of this change is that we won't
be calculating "weights" for LSQ2 with no weights (we used to calculate
these weights and store them in vectors for no use before).

Trace measurements for only the "getVelocity" code block show ~2x
improvements in time taken to executre "getVelocity".

Bug: 271935895
Test: atest libinput_tests
Change-Id: Id27bcbb183556479b9499b003823d3b0adec0423
parent 243d3dff
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment