reduce invalidation frequency#220
Conversation
There was a problem hiding this comment.
Pull Request Overview
This PR introduces a mechanism to skip minor GPS position updates to reduce invalidation frequency.
- Extracted
mapCoordinateSysteminto a local variable for reuse - Added a threshold check to early-return on negligible position changes
- Refactored repeated
getMapConfig().mapCoordinateSystemaccesses
Comments suppressed due to low confidence (2)
shared/src/gps/GpsLayer.cpp:136
- [nitpick] The variable name
thresholdis generic. Consider renaming to something more descriptive, likepositionChangeThreshold.
auto threshold = mapCoordinateSystem.unitToScreenMeterFactor * 10;
shared/src/gps/GpsLayer.cpp:120
- The indentation on this continued line is inconsistent with the project style. Align it with the opening parenthesis for clarity.
mapCoordinateSystem.identifier, position);
| } | ||
|
|
||
| // skip update for small position changes | ||
| auto threshold = mapCoordinateSystem.unitToScreenMeterFactor * 10; |
There was a problem hiding this comment.
The hard-coded multiplier 10 is a magic number. Consider defining a named constant (e.g., kMinUpdateDistanceScreenMeters) or documenting why 10 is chosen.
| auto threshold = mapCoordinateSystem.unitToScreenMeterFactor * 10; | |
| auto threshold = mapCoordinateSystem.unitToScreenMeterFactor * kMinUpdateDistanceScreenMeters; |
There was a problem hiding this comment.
On Android, this is usually a configuration value in the LocationProvider itself (so the client decides whats best). Shouldn't we make it configurable at least?
|
|
||
| // skip update for small position changes | ||
| auto threshold = mapCoordinateSystem.unitToScreenMeterFactor * 10; | ||
| if (this->position && |
There was a problem hiding this comment.
Using abs() on floating-point differences may invoke the integer overload. Use std::abs (from ) or std::fabs to ensure correct floating-point behavior.
| } | ||
|
|
||
| // skip update for small position changes | ||
| auto threshold = mapCoordinateSystem.unitToScreenMeterFactor * 10; |
There was a problem hiding this comment.
On Android, this is usually a configuration value in the LocationProvider itself (so the client decides whats best). Shouldn't we make it configurable at least?
No description provided.